1/*
2 * scr.h
3 *
4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 *  * Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *  * Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in
15 *    the documentation and/or other materials provided with the
16 *    distribution.
17 *  * Neither the name Texas Instruments nor the names of its
18 *    contributors may be used to endorse or promote products derived
19 *    from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file  scr.h
35 *  \brief This file includes internal (private) definitions to the SCR module
36 *
37 *  \see   scrApi.h, scr.c
38 */
39
40
41#ifndef __SCR_H__
42#define __SCR_H__
43
44#include "scrApi.h"
45
46/*
47 ***********************************************************************
48 *  Constant definitions.
49 ***********************************************************************
50 */
51
52 /*
53 ***********************************************************************
54 *  Enums.
55 ***********************************************************************
56 */
57
58/** \enum EScrClientState
59 * \brief enumerates the different states a client may be in .\n
60 */
61typedef enum
62{
63    SCR_CS_IDLE = 0,    /**< client is idle */
64    SCR_CS_PENDING,     /**< client is pending to use the channel */
65    SCR_CS_RUNNING,     /**< client is using the channel */
66    SCR_CS_ABORTING     /**<
67                         * client was using the channel, but was aborted,
68                         * and complete notification is expected.
69                         */
70} EScrClientState;
71
72
73/*
74 ***********************************************************************
75 *  Typedefs.
76 ***********************************************************************
77 */
78
79/*
80 ***********************************************************************
81 *  Structure definitions.
82 ***********************************************************************
83 */
84
85/** \struct TScrClient
86 * \brief This structure contains information for a specific client
87 */
88typedef struct
89{
90    EScrClientState     state[ SCR_RESOURCE_NUM_OF_RESOURCES ];     /**< the client current state, per resource */
91    TScrCB              clientRequestCB;                            /**< the client's callback function */
92    TI_HANDLE           ClientRequestCBObj;                         /**< the client's object */
93    EScePendReason      currentPendingReason[ SCR_RESOURCE_NUM_OF_RESOURCES ];
94                                                                    /**<
95                                                                     * the reason why this client is pending
96                                                                     * (if at all)
97                                                                     */
98} TScrClient;
99
100/** \struct TScr
101 * \brief This structure contains the SCR object data
102 */
103typedef struct
104{
105    TI_HANDLE               hOS;                                    /**< a handle to the OS object */
106    TI_HANDLE               hReport;                                /**< a handle to the report object */
107    TI_BOOL                 statusNotficationPending;               /**<
108                                                                     * whether the SCR is in the process of
109                                                                     * notifying a status change to a client
110                                                                     * (used to solve re-entrance problem)
111                                                                     */
112    EScrClientId            runningClient[ SCR_RESOURCE_NUM_OF_RESOURCES ];
113                                                                    /**<
114                                                                     * The index of the current running client
115                                                                     * (SCR_CID_NO_CLIENT if none), per resource
116                                                                     */
117    EScrGroupId             currentGroup;                           /**< the current group */
118    EScrModeId              currentMode;                            /**< the current mode */
119    TScrClient              clientArray[ SCR_CID_NUM_OF_CLIENTS ];  /**< array holding all clients' info */
120} TScr;
121
122
123/*
124 ***********************************************************************
125 *  External functions definitions
126 ***********************************************************************
127 */
128/**
129 * \\n
130 * \date 01-Dec-2004\n
131 * \brief Searches the client database for a client with matching state, from startFrom to endAt\n
132 *
133 * Function Scope \e Private.\n
134 * \param hScr - handle to the SCR object.\n
135 * \param requiredState - the state to match.\n
136 * \param eResource - the resource to macth.\n
137 * \param startFrom - the highest priority to begin searching from.\n
138 * \param endAt - the lowest priority to include in the search.\n
139 * \return the client ID if found, SCR_CID_NO_CLIENT if not found.\n
140 */
141EScrClientId scrFindHighest( TI_HANDLE hScr,
142                             EScrClientState requiredState,
143                             EScrResourceId eResource,
144                             TI_UINT32 startFrom,
145                             TI_UINT32 endAt );
146
147#endif /* __SCR_H__ */
148