omap3530/beagle_drivers/wb/api/src/cyasmtp.c
author arunabha
Thu, 16 Sep 2010 14:35:26 +0100
changeset 70 ed23a53a5ee2
parent 23 117faf51deac
permissions -rw-r--r--
Fixing issues in base_beagle.iby which had references to DEBUG_DIR
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     1
/* Cypress West Bridge API header file (cyasmtp.h)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     2
## ===========================
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     3
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     4
##  Copyright Cypress Semiconductor Corporation, 2006-2009,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     5
##  All Rights Reserved
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     6
##  UNPUBLISHED, LICENSED SOFTWARE.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     7
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     8
##  CONFIDENTIAL AND PROPRIETARY INFORMATION
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     9
##  WHICH IS THE PROPERTY OF CYPRESS.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    10
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    11
##  Use of this file is governed
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    12
##  by the license agreement included in the file
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    13
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    14
##     <install>/license/license.txt
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    15
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    16
##  where <install> is the Cypress software
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    17
##  installation root directory path.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    18
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    19
## ===========================
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    20
*/
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    21
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    22
#include "cyashal.h"
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    23
#include "cyasmtp.h"
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    24
#include "cyaserr.h"
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    25
#include "cyasdma.h"
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    26
#include "cyaslowlevel.h"
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    27
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    28
static void
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    29
CyAsMTPFuncCallback(CyAsDevice *dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    30
                    uint8_t context,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    31
                    CyAsLLRequestResponse *rqt,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    32
                    CyAsLLRequestResponse *resp,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    33
                    CyAsReturnStatus_t stat) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    34
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    35
static CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    36
IsMTPActive(CyAsDevice *dev_p)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    37
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    38
    if (!CyAsDeviceIsConfigured(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    39
        return CY_AS_ERROR_NOT_CONFIGURED ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    40
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    41
    if (!CyAsDeviceIsFirmwareLoaded(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    42
        return CY_AS_ERROR_NO_FIRMWARE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    43
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    44
    if (dev_p->mtp_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    45
        return CY_AS_ERROR_NOT_RUNNING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    46
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    47
    if (CyAsDeviceIsInSuspendMode(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    48
        return CY_AS_ERROR_IN_SUSPEND ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    49
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    50
    return CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    51
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    52
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    53
static void
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    54
MyMtpRequestCallback(CyAsDevice *dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    55
                     uint8_t context,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    56
                     CyAsLLRequestResponse *req_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    57
                     CyAsLLRequestResponse *resp_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    58
                     CyAsReturnStatus_t ret)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    59
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    60
    uint16_t val, ev, status ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    61
    uint16_t mtp_datalen = 0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    62
    uint32_t bytecount_l, bytecount_h ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    63
    CyAsMTPSendObjectCompleteData sendObjData ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    64
    CyAsMTPGetObjectCompleteData  getObjData ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    65
    CyAsDmaEndPoint *ep_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    66
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    67
    uint8_t code = CyAsLLRequestResponse_GetCode(req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    68
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    69
    (void)resp_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    70
    (void)context ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    71
    (void)ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    72
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    73
    switch(code)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    74
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    75
    case CY_RQT_MTP_EVENT:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    76
        val = CyAsLLRequestResponse_GetWord(req_p, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    77
        status = (val >> 8) & 0xFF ; /* MSB indicates status of read/write */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    78
        ev =   val & 0xFF ; /* event type */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    79
        switch(ev)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    80
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    81
        case 0: /* SendObject Complete */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    82
            {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    83
                bytecount_l = CyAsLLRequestResponse_GetWord(req_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    84
                bytecount_h = CyAsLLRequestResponse_GetWord(req_p, 2) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    85
                sendObjData.byte_count = (bytecount_h << 16) | bytecount_l ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    86
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    87
                sendObjData.status = status ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    88
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    89
                /* use the byte count again */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    90
                bytecount_l = CyAsLLRequestResponse_GetWord(req_p, 3) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    91
                bytecount_h = CyAsLLRequestResponse_GetWord(req_p, 4) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    92
                sendObjData.transaction_id = (bytecount_h << 16) | bytecount_l ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    93
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    94
                dev_p->mtp_turbo_active = CyFalse ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    95
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    96
                if (dev_p->mtp_event_cb)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    97
                    dev_p->mtp_event_cb((CyAsDeviceHandle)dev_p,  CyAsMTPSendObjectComplete,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    98
                                        &sendObjData) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    99
            }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   100
            break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   101
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   102
        case 1: /* GetObject Complete */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   103
            {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   104
                bytecount_l = CyAsLLRequestResponse_GetWord(req_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   105
                bytecount_h = CyAsLLRequestResponse_GetWord(req_p, 2) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   106
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   107
                getObjData.byte_count = (bytecount_h << 16) | bytecount_l ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   108
                getObjData.status = status ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   109
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   110
                dev_p->mtp_turbo_active = CyFalse ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   111
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   112
                if (dev_p->mtp_event_cb)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   113
                    dev_p->mtp_event_cb((CyAsDeviceHandle)dev_p,  CyAsMTPGetObjectComplete,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   114
                                        &getObjData);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   115
            }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   116
            break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   117
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   118
        case 2: /* BlockTable Needed */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   119
            {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   120
                if (dev_p->mtp_event_cb)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   121
                    dev_p->mtp_event_cb((CyAsDeviceHandle)dev_p,  CyAsMTPBlockTableNeeded, 0);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   122
            }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   123
            break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   124
        default:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   125
            CyAsHalPrintMessage("Invalid event type\n") ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   126
            CyAsLLSendDataResponse(dev_p, CY_RQT_TUR_RQT_CONTEXT, CY_RESP_MTP_INVALID_EVENT, sizeof(ev), &ev) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   127
            break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   128
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   129
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   130
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   131
    case CY_RQT_TURBO_CMD_FROM_HOST:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   132
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   133
            mtp_datalen = CyAsLLRequestResponse_GetWord(req_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   134
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   135
            /* Get the endpoint pointer based on the endpoint number */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   136
            ep_p = CY_AS_NUM_EP(dev_p, CY_AS_MTP_READ_ENDPOINT) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   137
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   138
            /* The event should arrive only after the DMA operation has been queued. */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   139
            CyAsHalAssert(ep_p->queue_p != 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   140
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   141
            /* Put the len in ep data information in dmaqueue and kick start the queue */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   142
            CyAsHalAssert(ep_p->queue_p->size >= mtp_datalen) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   143
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   144
            if (mtp_datalen == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   145
            {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   146
                CyAsDmaCompletedCallback(dev_p->tag, CY_AS_MTP_READ_ENDPOINT, 0, CY_AS_ERROR_SUCCESS) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   147
            }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   148
            else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   149
            {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   150
                ep_p->maxhwdata = mtp_datalen ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   151
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   152
                /*
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   153
                 * Make sure that the DMA status for this EP is not running, so that
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   154
                 * the call to CyAsDmaKickStart gets this transfer going.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   155
                 * Note: In MTP mode, we never leave a DMA transfer of greater than one
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   156
                 * packet running. So, it is okay to override the status here and start
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   157
                 * the next packet transfer.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   158
                 */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   159
                CyAsDmaEndPointSetStopped(ep_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   160
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   161
                /* Kick start the queue if it is not running */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   162
                CyAsDmaKickStart(dev_p, CY_AS_MTP_READ_ENDPOINT) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   163
            }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   164
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   165
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   166
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   167
    case CY_RQT_TURBO_START_WRITE_DMA:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   168
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   169
            /*
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   170
             * Now that the firmware is ready to receive the next packet of data, start
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   171
             * the corresponding DMA transfer.  First, ensure that a DMA operation is still
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   172
             * pending in the queue for the write endpoint.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   173
             */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   174
            CyAsLLSendStatusResponse(dev_p, CY_RQT_TUR_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   175
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   176
            ep_p = CY_AS_NUM_EP(dev_p, CY_AS_MTP_WRITE_ENDPOINT) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   177
            CyAsHalAssert (ep_p->queue_p != 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   178
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   179
            CyAsDmaEndPointSetStopped(ep_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   180
            CyAsDmaKickStart(dev_p, CY_AS_MTP_WRITE_ENDPOINT) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   181
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   182
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   183
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   184
    default:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   185
        CyAsHalPrintMessage("Invalid request received on TUR context\n") ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   186
        val = req_p->box0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   187
        CyAsLLSendDataResponse(dev_p, CY_RQT_TUR_RQT_CONTEXT, CY_RESP_INVALID_REQUEST, sizeof(val), &val) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   188
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   189
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   190
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   191
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   192
static CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   193
MyHandleResponseNoData(CyAsDevice* dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   194
                         CyAsLLRequestResponse *req_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   195
                         CyAsLLRequestResponse *reply_p)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   196
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   197
    CyAsReturnStatus_t ret = CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   198
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   199
    if (CyAsLLRequestResponse_GetCode(reply_p) != CY_RESP_SUCCESS_FAILURE)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   200
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   201
        ret = CY_AS_ERROR_INVALID_RESPONSE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   202
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   203
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   204
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   205
    ret = CyAsLLRequestResponse_GetWord(reply_p, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   206
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   207
destroy :
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   208
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   209
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   210
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   211
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   212
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   213
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   214
static CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   215
MyHandleResponseMTPStart(CyAsDevice* dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   216
                         CyAsLLRequestResponse *req_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   217
                         CyAsLLRequestResponse *reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   218
                         CyAsReturnStatus_t ret)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   219
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   220
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   221
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   222
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   223
    if (CyAsLLRequestResponse_GetCode(reply_p) != CY_RESP_SUCCESS_FAILURE)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   224
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   225
        ret = CY_AS_ERROR_INVALID_RESPONSE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   226
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   227
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   228
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   229
    ret = CyAsLLRequestResponse_GetWord(reply_p, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   230
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   231
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   232
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   233
    dev_p->mtp_count++ ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   234
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   235
    CyAsDmaEnableEndPoint(dev_p, CY_AS_MTP_READ_ENDPOINT, CyTrue, CyAsDirectionOut) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   236
    dev_p->usb_config[CY_AS_MTP_READ_ENDPOINT].enabled = CyTrue ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   237
    dev_p->usb_config[CY_AS_MTP_READ_ENDPOINT].dir = CyAsUsbOut ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   238
    dev_p->usb_config[CY_AS_MTP_READ_ENDPOINT].type = CyAsUsbBulk ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   239
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   240
    CyAsDmaEnableEndPoint(dev_p, CY_AS_MTP_WRITE_ENDPOINT, CyTrue, CyAsDirectionIn) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   241
    dev_p->usb_config[CY_AS_MTP_WRITE_ENDPOINT].enabled = CyTrue ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   242
    dev_p->usb_config[CY_AS_MTP_WRITE_ENDPOINT].dir = CyAsUsbIn ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   243
    dev_p->usb_config[CY_AS_MTP_WRITE_ENDPOINT].type = CyAsUsbBulk ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   244
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   245
    CyAsDmaSetMaxDmaSize(dev_p, 0x02, 0x0200) ; /* Packet size is 512 bytes */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   246
    CyAsDmaSetMaxDmaSize(dev_p, 0x06, 0x40) ;   /* Packet size is 64 bytes until a switch to high speed happens. */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   247
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   248
destroy :
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   249
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   250
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   251
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   252
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   253
        CyAsLLRegisterRequestCallback(dev_p, CY_RQT_TUR_RQT_CONTEXT, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   254
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   255
    CyAsDeviceClearMSSPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   256
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   257
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   258
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   259
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   260
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   261
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   262
CyAsMTPStart(CyAsDeviceHandle handle,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   263
             CyAsMTPEventCallback eventCB,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   264
             CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   265
             uint32_t client
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   266
             )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   267
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   268
    CyAsLLRequestResponse *req_p, *reply_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   269
    CyAsReturnStatus_t ret = CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   270
    CyAsDevice* dev_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   271
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   272
    dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   273
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   274
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   275
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   276
    if (!CyAsDeviceIsConfigured(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   277
        return CY_AS_ERROR_NOT_CONFIGURED ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   278
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   279
    if (!CyAsDeviceIsFirmwareLoaded(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   280
        return CY_AS_ERROR_NO_FIRMWARE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   281
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   282
    if (CyAsDeviceIsInSuspendMode(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   283
        return CY_AS_ERROR_IN_SUSPEND ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   284
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   285
    if (CyAsDeviceIsInCallback(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   286
        return CY_AS_ERROR_INVALID_IN_CALLBACK ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   287
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   288
    if(CyAsDeviceIsMSSPending(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   289
        return CY_AS_ERROR_STARTSTOP_PENDING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   290
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   291
    if (dev_p->storage_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   292
        return CY_AS_ERROR_NOT_RUNNING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   293
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   294
    if (dev_p->usb_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   295
        return CY_AS_ERROR_NOT_RUNNING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   296
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   297
    if (dev_p->is_mtp_firmware == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   298
        return CY_AS_ERROR_NOT_SUPPORTED ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   299
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   300
    CyAsDeviceSetMSSPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   301
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   302
    if (dev_p->mtp_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   303
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   304
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   305
        dev_p->mtp_event_cb = eventCB ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   306
        /*
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   307
        * We register here becuase the start request may cause events to occur before the
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   308
        * response to the start request.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   309
        */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   310
        CyAsLLRegisterRequestCallback(dev_p, CY_RQT_TUR_RQT_CONTEXT, MyMtpRequestCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   311
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   312
        /* Create the request to send to the West Bridge device */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   313
        req_p = CyAsLLCreateRequest(dev_p, CY_RQT_START_MTP, CY_RQT_TUR_RQT_CONTEXT, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   314
        if (req_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   315
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   316
            CyAsDeviceClearMSSPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   317
            return CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   318
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   319
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   320
        /* Reserve space for the reply, the reply data will not exceed one word */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   321
        reply_p = CyAsLLCreateResponse(dev_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   322
        if (reply_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   323
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   324
            CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   325
            CyAsDeviceClearMSSPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   326
            return CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   327
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   328
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   329
        if(cb == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   330
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   331
            ret = CyAsLLSendRequestWaitReply(dev_p, req_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   332
            if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   333
                goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   334
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   335
            return MyHandleResponseMTPStart(dev_p, req_p, reply_p, ret) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   336
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   337
        else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   338
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   339
            ret = CyAsMiscSendRequest(dev_p, cb, client, CY_FUNCT_CB_MTP_START,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   340
                0, dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   341
                CyAsMTPFuncCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   342
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   343
            if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   344
                goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   345
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   346
            return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   347
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   348
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   349
destroy:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   350
        CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   351
        CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   352
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   353
    else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   354
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   355
        dev_p->mtp_count++ ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   356
        if (cb)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   357
            cb(handle, ret, client, CY_FUNCT_CB_MTP_START, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   358
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   359
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   360
    CyAsDeviceClearMSSPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   361
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   362
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   363
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   364
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   365
static CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   366
MyHandleResponseMTPStop(CyAsDevice* dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   367
                        CyAsLLRequestResponse *req_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   368
                        CyAsLLRequestResponse *reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   369
                        CyAsReturnStatus_t ret)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   370
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   371
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   372
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   373
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   374
    if (CyAsLLRequestResponse_GetCode(reply_p) != CY_RESP_SUCCESS_FAILURE)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   375
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   376
        ret = CY_AS_ERROR_INVALID_RESPONSE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   377
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   378
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   379
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   380
    ret = CyAsLLRequestResponse_GetWord(reply_p, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   381
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   382
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   383
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   384
    /*
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   385
    * We sucessfully shutdown the stack, so decrement to make the count
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   386
    * zero.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   387
    */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   388
    dev_p->mtp_count-- ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   389
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   390
destroy :
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   391
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   392
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   393
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   394
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   395
        CyAsLLRegisterRequestCallback(dev_p, CY_RQT_TUR_RQT_CONTEXT, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   396
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   397
    CyAsDeviceClearMSSPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   398
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   399
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   400
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   401
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   402
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   403
CyAsMTPStop(CyAsDeviceHandle handle,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   404
            CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   405
            uint32_t client
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   406
            )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   407
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   408
    CyAsLLRequestResponse *req_p = 0, *reply_p = 0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   409
    CyAsReturnStatus_t ret = CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   410
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   411
    CyAsDevice*dev_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   412
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   413
    CyAsLogDebugMessage(6, "CyAsMTPStop called") ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   414
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   415
    dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   416
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   417
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   418
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   419
    ret = IsMTPActive(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   420
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   421
        return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   422
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   423
    if (CyAsDeviceIsInCallback(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   424
        return CY_AS_ERROR_INVALID_IN_CALLBACK ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   425
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   426
    if(CyAsDeviceIsMSSPending(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   427
        return CY_AS_ERROR_STARTSTOP_PENDING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   428
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   429
    CyAsDeviceSetMSSPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   430
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   431
    if (dev_p->mtp_count == 1)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   432
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   433
        /* Create the request to send to the West Bridge device */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   434
        req_p = CyAsLLCreateRequest(dev_p, CY_RQT_STOP_MTP, CY_RQT_TUR_RQT_CONTEXT, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   435
        if (req_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   436
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   437
            ret = CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   438
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   439
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   440
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   441
        /* Reserve space for the reply, the reply data will not exceed one word */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   442
        reply_p = CyAsLLCreateResponse(dev_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   443
        if (reply_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   444
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   445
            ret = CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   446
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   447
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   448
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   449
        if(cb == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   450
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   451
            ret = CyAsLLSendRequestWaitReply(dev_p, req_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   452
            if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   453
                goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   454
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   455
            return MyHandleResponseMTPStop(dev_p, req_p, reply_p, ret) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   456
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   457
        else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   458
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   459
            ret = CyAsMiscSendRequest(dev_p, cb, client, CY_FUNCT_CB_MTP_STOP,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   460
                0, dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   461
                CyAsMTPFuncCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   462
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   463
            if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   464
                goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   465
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   466
            return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   467
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   468
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   469
destroy:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   470
        CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   471
        CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   472
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   473
    else if (dev_p->mtp_count > 1)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   474
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   475
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   476
        dev_p->mtp_count-- ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   477
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   478
        if (cb)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   479
            cb(handle, ret, client, CY_FUNCT_CB_MTP_STOP, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   480
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   481
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   482
    CyAsDeviceClearMSSPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   483
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   484
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   485
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   486
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   487
static void
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   488
MtpWriteCallback(
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   489
        CyAsDevice *dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   490
        uint8_t context,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   491
        CyAsLLRequestResponse *rqt,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   492
        CyAsLLRequestResponse *resp,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   493
        CyAsReturnStatus_t ret)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   494
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   495
    CyAsHalAssert(context == CY_RQT_TUR_RQT_CONTEXT) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   496
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   497
    if (ret == CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   498
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   499
        if (CyAsLLRequestResponse_GetCode(resp) != CY_RESP_SUCCESS_FAILURE)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   500
            ret = CY_AS_ERROR_INVALID_RESPONSE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   501
        else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   502
            ret = CyAsLLRequestResponse_GetWord(resp, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   503
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   504
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   505
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   506
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   507
        /* Firmware failed the request. Cancel the DMA transfer. */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   508
        CyAsDmaCancel(dev_p, 0x04, CY_AS_ERROR_CANCELED) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   509
        CyAsDeviceClearStorageAsyncPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   510
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   511
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   512
    CyAsLLDestroyResponse(dev_p, resp) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   513
    CyAsLLDestroyRequest(dev_p, rqt) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   514
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   515
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   516
static void
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   517
AsyncWriteRequestCallback(CyAsDevice *dev_p, CyAsEndPointNumber_t ep, void *buf_p, uint32_t size, CyAsReturnStatus_t err)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   518
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   519
    CyAsDeviceHandle h ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   520
    CyAsFunctionCallback cb ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   521
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   522
    (void)size ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   523
    (void)buf_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   524
    (void)ep ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   525
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   526
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   527
    CyAsLogDebugMessage(6, "AsyncWriteRequestCallback called") ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   528
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   529
    h = (CyAsDeviceHandle)dev_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   530
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   531
    cb = dev_p->mtp_cb ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   532
    dev_p->mtp_cb = 0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   533
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   534
    CyAsDeviceClearStorageAsyncPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   535
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   536
    if (cb)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   537
        cb(h, err, dev_p->mtp_client, dev_p->mtp_op, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   538
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   539
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   540
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   541
static void
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   542
SyncMTPCallback(CyAsDevice *dev_p, CyAsEndPointNumber_t ep, void *buf_p, uint32_t size, CyAsReturnStatus_t err)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   543
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   544
    (void)ep ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   545
    (void)buf_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   546
    (void)size ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   547
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   548
    dev_p->mtp_error = err ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   549
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   550
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   551
static CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   552
CyAsMTPOperation(CyAsDevice *dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   553
                 CyAsMTPBlockTable* blk_table,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   554
                 uint32_t num_bytes,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   555
                 uint32_t transaction_id,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   556
                 CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   557
                 uint32_t client,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   558
                 uint8_t rqttype
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   559
                 )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   560
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   561
    CyAsLLRequestResponse *req_p = 0, *reply_p = 0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   562
    CyAsReturnStatus_t ret = CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   563
    uint32_t mask = 0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   564
    CyAsFunctCBType mtp_cb_op = (CyAsFunctCBType)0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   565
    uint16_t size = 2 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   566
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   567
        if(dev_p->mtp_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   568
                return CY_AS_ERROR_NOT_RUNNING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   569
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   570
    if (rqttype == CY_RQT_INIT_SEND_OBJECT)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   571
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   572
        mtp_cb_op = CY_FUNCT_CB_MTP_INIT_SEND_OBJECT ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   573
        dev_p->mtp_turbo_active = CyTrue ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   574
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   575
    else if (rqttype == CY_RQT_INIT_GET_OBJECT)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   576
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   577
        mtp_cb_op = CY_FUNCT_CB_MTP_INIT_GET_OBJECT ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   578
        dev_p->mtp_turbo_active = CyTrue ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   579
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   580
    else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   581
        mtp_cb_op = CY_FUNCT_CB_MTP_SEND_BLOCK_TABLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   582
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   583
    ret = IsMTPActive(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   584
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   585
        return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   586
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   587
    if (CY_RQT_INIT_GET_OBJECT == rqttype)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   588
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   589
        size = 4 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   590
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   591
    /* Create the request to send to the West Bridge device */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   592
    req_p = CyAsLLCreateRequest(dev_p, rqttype, CY_RQT_TUR_RQT_CONTEXT, size) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   593
    if (req_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   594
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   595
        ret = CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   596
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   597
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   598
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   599
    /* Reserve space for the reply, the reply data will not exceed one word */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   600
    reply_p = CyAsLLCreateResponse(dev_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   601
    if (reply_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   602
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   603
        ret = CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   604
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   605
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   606
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   607
    CyAsLLRequestResponse_SetWord(req_p, 0, (uint16_t)(num_bytes & 0xFFFF)) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   608
    CyAsLLRequestResponse_SetWord(req_p, 1, (uint16_t)((num_bytes >> 16) & 0xFFFF)) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   609
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   610
    /* If it is GET_OBJECT, send transaction id as well */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   611
    if (CY_RQT_INIT_GET_OBJECT == rqttype)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   612
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   613
        CyAsLLRequestResponse_SetWord(req_p, 2, (uint16_t)(transaction_id & 0xFFFF)) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   614
        CyAsLLRequestResponse_SetWord(req_p, 3, (uint16_t)((transaction_id >> 16) & 0xFFFF)) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   615
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   616
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   617
    if(cb == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   618
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   619
        /* Queue the DMA request for block table write */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   620
        ret = CyAsDmaQueueRequest(dev_p, 4, blk_table, sizeof(CyAsMTPBlockTable), CyFalse, CyFalse, SyncMTPCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   621
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   622
        ret = CyAsLLSendRequestWaitReply(dev_p, req_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   623
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   624
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   625
            CyAsDmaCancel(dev_p, 4, CY_AS_ERROR_CANCELED) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   626
            CyAsDeviceClearStorageAsyncPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   627
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   628
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   629
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   630
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   631
        ret = CyAsDmaDrainQueue(dev_p, 4, CyTrue) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   632
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   633
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   634
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   635
        ret = dev_p->mtp_error ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   636
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   637
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   638
    else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   639
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   640
#if 0
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   641
        ret = CyAsMiscSendRequest(dev_p, cb, client, CY_FUNCT_CB_MTP_INIT_SEND_OBJECT,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   642
            0, dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   643
            CyAsMTPFuncCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   644
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   645
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   646
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   647
#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   648
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   649
        /* Protection from interrupt driven code */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   650
        /* since we are using storage EP4 check if any storage activity is pending */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   651
        mask = CyAsHalDisableInterrupts() ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   652
        if ((CyAsDeviceIsStorageAsyncPending(dev_p)) || (dev_p->storage_wait))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   653
        {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   654
            CyAsHalEnableInterrupts(mask) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   655
            return CY_AS_ERROR_ASYNC_PENDING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   656
        }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   657
        CyAsDeviceSetStorageAsyncPending(dev_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   658
        CyAsHalEnableInterrupts(mask) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   659
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   660
        dev_p->mtp_cb     = cb ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   661
        dev_p->mtp_client = client ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   662
        dev_p->mtp_op     = mtp_cb_op ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   663
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   664
        ret = CyAsLLSendRequest(dev_p, req_p, reply_p, CyFalse, MtpWriteCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   665
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   666
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   667
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   668
        ret = CyAsDmaQueueRequest(dev_p, 4, blk_table, sizeof(CyAsMTPBlockTable), CyFalse, CyFalse, AsyncWriteRequestCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   669
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   670
            return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   671
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   672
        /* Kick start the queue if it is not running */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   673
        CyAsDmaKickStart(dev_p, 4) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   674
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   675
        return CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   676
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   677
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   678
destroy:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   679
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   680
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   681
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   682
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   683
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   684
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   685
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   686
CyAsMTPInitSendObject(CyAsDeviceHandle handle,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   687
                      CyAsMTPBlockTable* blk_table,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   688
                      uint32_t num_bytes,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   689
                      CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   690
                      uint32_t client
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   691
                      )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   692
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   693
    CyAsDevice* dev_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   694
    dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   695
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   696
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   697
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   698
    return CyAsMTPOperation(dev_p, blk_table, num_bytes, 0, cb, client, CY_RQT_INIT_SEND_OBJECT) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   699
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   700
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   701
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   702
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   703
CyAsMTPInitGetObject(CyAsDeviceHandle handle,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   704
                     CyAsMTPBlockTable* blk_table,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   705
                     uint32_t num_bytes,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   706
                     uint32_t transaction_id,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   707
                     CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   708
                     uint32_t client
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   709
                     )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   710
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   711
    CyAsDevice* dev_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   712
    dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   713
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   714
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   715
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   716
    return CyAsMTPOperation(dev_p, blk_table, num_bytes, transaction_id, cb, client, CY_RQT_INIT_GET_OBJECT) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   717
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   718
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   719
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   720
static CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   721
MyHandleResponseCancelSendObject(CyAsDevice* dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   722
                                 CyAsLLRequestResponse *req_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   723
                                 CyAsLLRequestResponse *reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   724
                                 CyAsReturnStatus_t ret)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   725
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   726
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   727
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   728
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   729
    if (CyAsLLRequestResponse_GetCode(reply_p) != CY_RESP_SUCCESS_FAILURE)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   730
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   731
        ret = CY_AS_ERROR_INVALID_RESPONSE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   732
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   733
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   734
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   735
    ret = CyAsLLRequestResponse_GetWord(reply_p, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   736
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   737
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   738
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   739
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   740
destroy :
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   741
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   742
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   743
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   744
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   745
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   746
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   747
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   748
CyAsMTPCancelSendObject(CyAsDeviceHandle handle,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   749
                        CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   750
                        uint32_t client
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   751
                        )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   752
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   753
    CyAsLLRequestResponse *req_p = 0, *reply_p = 0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   754
    CyAsReturnStatus_t ret = CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   755
    CyAsDevice*dev_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   756
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   757
    dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   758
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   759
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   760
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   761
        if(dev_p->mtp_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   762
                return CY_AS_ERROR_NOT_RUNNING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   763
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   764
    /* Create the request to send to the West Bridge device */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   765
    req_p = CyAsLLCreateRequest(dev_p, CY_RQT_CANCEL_SEND_OBJECT, CY_RQT_TUR_RQT_CONTEXT, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   766
    if (req_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   767
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   768
        ret = CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   769
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   770
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   771
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   772
    /* Reserve space for the reply, the reply data will not exceed one word */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   773
    reply_p = CyAsLLCreateResponse(dev_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   774
    if (reply_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   775
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   776
        ret = CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   777
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   778
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   779
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   780
    if(cb == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   781
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   782
        ret = CyAsLLSendRequestWaitReply(dev_p, req_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   783
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   784
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   785
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   786
        return MyHandleResponseCancelSendObject(dev_p, req_p, reply_p, ret) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   787
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   788
    else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   789
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   790
        ret = CyAsMiscSendRequest(dev_p, cb, client, CY_FUNCT_CB_MTP_CANCEL_SEND_OBJECT,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   791
            0, dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   792
            CyAsMTPFuncCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   793
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   794
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   795
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   796
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   797
        return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   798
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   799
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   800
destroy :
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   801
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   802
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   803
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   804
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   805
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   806
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   807
static CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   808
MyHandleResponseCancelGetObject(CyAsDevice* dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   809
                                CyAsLLRequestResponse *req_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   810
                                CyAsLLRequestResponse *reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   811
                                CyAsReturnStatus_t ret)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   812
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   813
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   814
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   815
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   816
    if (CyAsLLRequestResponse_GetCode(reply_p) != CY_RESP_SUCCESS_FAILURE)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   817
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   818
        ret = CY_AS_ERROR_INVALID_RESPONSE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   819
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   820
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   821
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   822
    ret = CyAsLLRequestResponse_GetWord(reply_p, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   823
    if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   824
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   825
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   826
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   827
destroy :
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   828
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   829
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   830
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   831
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   832
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   833
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   834
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   835
CyAsMTPCancelGetObject(CyAsDeviceHandle handle,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   836
                       CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   837
                       uint32_t client
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   838
                       )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   839
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   840
    CyAsLLRequestResponse *req_p = 0, *reply_p = 0 ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   841
    CyAsReturnStatus_t ret = CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   842
    CyAsDevice*dev_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   843
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   844
    dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   845
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   846
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   847
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   848
        if(dev_p->mtp_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   849
                return CY_AS_ERROR_NOT_RUNNING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   850
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   851
    /* Create the request to send to the West Bridge device */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   852
    req_p = CyAsLLCreateRequest(dev_p, CY_RQT_CANCEL_GET_OBJECT, CY_RQT_TUR_RQT_CONTEXT, 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   853
    if (req_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   854
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   855
        ret = CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   856
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   857
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   858
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   859
    /* Reserve space for the reply, the reply data will not exceed one word */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   860
    reply_p = CyAsLLCreateResponse(dev_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   861
    if (reply_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   862
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   863
        ret = CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   864
        goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   865
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   866
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   867
    if(cb == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   868
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   869
        ret = CyAsLLSendRequestWaitReply(dev_p, req_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   870
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   871
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   872
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   873
        return MyHandleResponseCancelGetObject(dev_p, req_p, reply_p, ret) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   874
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   875
    else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   876
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   877
        ret = CyAsMiscSendRequest(dev_p, cb, client, CY_FUNCT_CB_MTP_CANCEL_GET_OBJECT,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   878
            0, dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   879
            CyAsMTPFuncCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   880
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   881
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   882
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   883
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   884
        return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   885
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   886
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   887
destroy:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   888
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   889
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   890
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   891
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   892
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   893
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   894
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   895
CyAsMTPSendBlockTable(CyAsDeviceHandle handle,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   896
                      CyAsMTPBlockTable* blk_table,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   897
                      CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   898
                      uint32_t client
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   899
                      )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   900
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   901
    CyAsDevice* dev_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   902
    dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   903
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   904
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   905
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   906
    return CyAsMTPOperation(dev_p, blk_table, 0, 0, cb, client, CY_RQT_SEND_BLOCK_TABLE) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   907
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   908
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   909
static void
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   910
CyAsMTPFuncCallback(CyAsDevice *dev_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   911
                    uint8_t context,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   912
                    CyAsLLRequestResponse *rqt,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   913
                    CyAsLLRequestResponse *resp,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   914
                    CyAsReturnStatus_t stat)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   915
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   916
    CyAsFuncCBNode*     node = (CyAsFuncCBNode*)dev_p->func_cbs_mtp->head_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   917
    CyAsReturnStatus_t  ret = CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   918
    uint8_t             code ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   919
    CyBool delay_callback = CyFalse ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   920
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   921
    CyAsHalAssert(dev_p->func_cbs_mtp->count != 0) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   922
    CyAsHalAssert(dev_p->func_cbs_mtp->type == CYAS_FUNC_CB) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   923
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   924
    (void)context ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   925
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   926
    /* The Handlers are responsible for Deleting the rqt and resp when
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   927
    * they are finished
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   928
    */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   929
    code = CyAsLLRequestResponse_GetCode(rqt) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   930
    switch(code)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   931
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   932
    case CY_RQT_START_MTP:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   933
        ret = MyHandleResponseMTPStart(dev_p, rqt, resp, stat) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   934
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   935
    case CY_RQT_STOP_MTP:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   936
        ret = MyHandleResponseMTPStop(dev_p, rqt, resp, stat) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   937
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   938
#if 0
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   939
    case CY_RQT_INIT_SEND_OBJECT:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   940
        ret = MyHandleResponseInitSendObject(dev_p, rqt, resp, stat, CyTrue) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   941
        delay_callback = CyTrue ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   942
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   943
#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   944
    case CY_RQT_CANCEL_SEND_OBJECT:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   945
        ret = MyHandleResponseCancelSendObject(dev_p, rqt, resp, stat) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   946
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   947
#if 0
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   948
    case CY_RQT_INIT_GET_OBJECT:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   949
        ret = MyHandleResponseInitGetObject(dev_p, rqt, resp, stat, CyTrue) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   950
        delay_callback = CyTrue ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   951
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   952
#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   953
    case CY_RQT_CANCEL_GET_OBJECT:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   954
        ret = MyHandleResponseCancelGetObject(dev_p, rqt, resp, stat) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   955
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   956
#if 0
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   957
    case CY_RQT_SEND_BLOCK_TABLE:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   958
        ret = MyHandleResponseSendBlockTable(dev_p, rqt, resp, stat, CyTrue) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   959
        delay_callback = CyTrue ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   960
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   961
#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   962
    case CY_RQT_ENABLE_USB_PATH:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   963
        ret = MyHandleResponseNoData(dev_p, rqt, resp) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   964
        if (ret == CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   965
            dev_p->is_storage_only_mode = CyFalse ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   966
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   967
    default:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   968
        ret = CY_AS_ERROR_INVALID_RESPONSE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   969
        CyAsHalAssert(CyFalse) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   970
        break ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   971
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   972
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   973
    /*
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   974
    * If the low level layer returns a direct error, use the corresponding error code.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   975
    * If not, use the error code based on the response from firmware.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   976
    */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   977
    if (stat == CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   978
        stat = ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   979
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   980
    if(!delay_callback)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   981
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   982
        node->cb_p((CyAsDeviceHandle)dev_p, stat, node->client_data, (CyAsFunctCBType)node->dataType, node->data) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   983
        CyAsRemoveCBNode(dev_p->func_cbs_mtp) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   984
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   985
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   986
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   987
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   988
CyAsMTPStorageOnlyStart(CyAsDeviceHandle handle)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   989
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   990
    CyAsDevice *dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   991
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   992
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   993
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   994
    if (!CyAsDeviceIsConfigured(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   995
        return CY_AS_ERROR_NOT_CONFIGURED ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   996
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   997
    if (!CyAsDeviceIsFirmwareLoaded(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   998
        return CY_AS_ERROR_NO_FIRMWARE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   999
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1000
    if (dev_p->storage_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1001
        return CY_AS_ERROR_NOT_RUNNING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1002
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1003
    dev_p->is_storage_only_mode = CyTrue ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1004
    return CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1005
}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1006
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1007
CyAsReturnStatus_t
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1008
CyAsMTPStorageOnlyStop(CyAsDeviceHandle handle,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1009
                        CyAsFunctionCallback cb,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1010
                        uint32_t client)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1011
{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1012
    CyAsDevice *dev_p = (CyAsDevice *)handle ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1013
    CyAsLLRequestResponse *req_p, *reply_p ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1014
    CyAsReturnStatus_t ret = CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1015
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1016
    if (!dev_p ||(dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1017
        return CY_AS_ERROR_INVALID_HANDLE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1018
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1019
    if (!CyAsDeviceIsConfigured(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1020
        return CY_AS_ERROR_NOT_CONFIGURED ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1021
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1022
    if (!CyAsDeviceIsFirmwareLoaded(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1023
        return CY_AS_ERROR_NO_FIRMWARE ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1024
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1025
    if (dev_p->storage_count == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1026
        return CY_AS_ERROR_NOT_RUNNING ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1027
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1028
    if (dev_p->is_storage_only_mode == CyFalse)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1029
        return CY_AS_ERROR_SUCCESS ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1030
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1031
    if (CyAsDeviceIsInCallback(dev_p))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1032
        return CY_AS_ERROR_INVALID_IN_CALLBACK ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1033
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1034
    req_p = CyAsLLCreateRequest(dev_p, CY_RQT_ENABLE_USB_PATH, CY_RQT_TUR_RQT_CONTEXT, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1035
    if (req_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1036
        return CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1037
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1038
    reply_p = CyAsLLCreateResponse(dev_p, 1) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1039
    if (reply_p == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1040
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1041
        CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1042
        return CY_AS_ERROR_OUT_OF_MEMORY ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1043
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1044
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1045
    if(cb == 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1046
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1047
        ret = CyAsLLSendRequestWaitReply(dev_p, req_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1048
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1049
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1050
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1051
        ret = MyHandleResponseNoData(dev_p, req_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1052
        if (ret == CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1053
            dev_p->is_storage_only_mode = CyFalse ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1054
        return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1055
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1056
    else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1057
    {
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1058
        ret = CyAsMiscSendRequest(dev_p, cb, client, CY_FUNCT_CB_MTP_STOP_STORAGE_ONLY,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1059
            0, dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1060
            CyAsMTPFuncCallback) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1061
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1062
        if (ret != CY_AS_ERROR_SUCCESS)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1063
            goto destroy ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1064
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1065
        return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1066
    }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1067
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1068
destroy:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1069
    CyAsLLDestroyRequest(dev_p, req_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1070
    CyAsLLDestroyResponse(dev_p, reply_p) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1071
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1072
    return ret ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1073
}