|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: GSServer is responsible for initializing the TV |
|
15 * driver during the boot and always when the cable is connected. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "GSLogger.h" |
|
21 #include "GSServerEngine.h" |
|
22 #include <AccessoriesCRKeys.h> |
|
23 |
|
24 #include <e32svr.h> |
|
25 #include <centralrepository.h> |
|
26 #include <data_caging_path_literals.hrh> |
|
27 #include <f32file.h> |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 |
|
36 // LOCAL CONSTANTS AND MACROS |
|
37 |
|
38 //For SwitchValue() |
|
39 const TInt KGSIndexOff = 1; |
|
40 const TInt KGSIndexOn = 0; |
|
41 const TInt KGSSettingOff = 0; |
|
42 const TInt KGSSettingOn = 1; |
|
43 //For aspect ratio conversion |
|
44 const TInt KGSTvAspectNormal = 0; |
|
45 const TInt KGSTvAspectWide = 1; |
|
46 //For tv system value conversion |
|
47 const TInt KGSTvSystemPal = 0; |
|
48 const TInt KGSTvSystemPalm = 1; |
|
49 const TInt KGSTvSystemNtsc = 2; |
|
50 |
|
51 // ============================ MEMBER FUNCTIONS =============================== |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CGSServerEngine::CGSServerEngine |
|
55 // C++ default constructor can NOT contain any code, that |
|
56 // might leave. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CGSServerEngine::CGSServerEngine() |
|
60 { |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CGSServerEngine::ConstructL |
|
65 // Create the display driver and central repository. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CGSServerEngine::ConstructL() |
|
69 { |
|
70 __GSLOGSTRING( "[CGSServerEngine] ConstructL()" ); |
|
71 iRepository = CRepository::NewL( KCRUidTvoutSettings ); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CGSServerEngine::NewL |
|
76 // Two-phased constructor. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C CGSServerEngine* CGSServerEngine::NewL() |
|
80 { |
|
81 __GSLOGSTRING( "[CGSServerEngine] NewL()" ); |
|
82 CGSServerEngine* self = CGSServerEngine::NewLC(); |
|
83 CleanupStack::Pop( self ); |
|
84 return self; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CGSServerEngine::NewLC |
|
89 // Two-phased constructor. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C CGSServerEngine* CGSServerEngine::NewLC() |
|
93 { |
|
94 __GSLOGSTRING( "[CGSServerEngine] NewLC()" ); |
|
95 CGSServerEngine* self = new ( ELeave ) CGSServerEngine(); |
|
96 CleanupStack::PushL( self ); |
|
97 self->ConstructL(); |
|
98 return self; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CGSServerEngine::NewLC |
|
103 // Destructor, close and release the handles. |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C CGSServerEngine::~CGSServerEngine() |
|
107 { |
|
108 __GSLOGSTRING( "[CGSServerEngine] ~CGSServerEngine()" ); |
|
109 delete iRepository; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CGSServerEngine::TvSystem |
|
114 // Get the value from the Central repository. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C TInt CGSServerEngine::TvSystemL() |
|
118 { |
|
119 __GSLOGSTRING( "[CGSServerEngine] TvSystemL()" ); |
|
120 TInt value; |
|
121 User::LeaveIfError( iRepository->Get( KSettingsTvSystemInfo, value ) ); |
|
122 |
|
123 return value; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CGSServerEngine::SetTvSystem |
|
128 // Set the value to the Central repository and initialize the driver. |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 EXPORT_C void CGSServerEngine::SetTvSystemL( const TInt aTvSystem ) |
|
132 { |
|
133 __GSLOGSTRING( "[CGSServerEngine] SetTvSystemL()" ); |
|
134 TInt err = iRepository->Set( KSettingsTvSystemInfo, aTvSystem ); |
|
135 User::LeaveIfError( err ); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CGSServerEngine::AspectRatioL |
|
140 // Get the value from the Central repository. |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C TInt CGSServerEngine::AspectRatioL() |
|
144 { |
|
145 __GSLOGSTRING( "[CGSServerEngine] AspectRatioL()" ); |
|
146 TInt value; |
|
147 User::LeaveIfError( iRepository->Get( KSettingsTvAspectRatio, value ) ); |
|
148 |
|
149 return value; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CGSServerEngine::SetAspectRatioL |
|
154 // Set the value to the Central repository and initialize the driver. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C void CGSServerEngine::SetAspectRatioL( const TInt aRatio ) |
|
158 { |
|
159 __GSLOGSTRING( "[CGSServerEngine] SetAspectRatioL()" ); |
|
160 TInt err = iRepository->Set( KSettingsTvAspectRatio, aRatio ); |
|
161 User::LeaveIfError( err ); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CGSServerEngine::FlickerFilter |
|
166 // Get the value from the Central repository. |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 EXPORT_C TInt CGSServerEngine::FlickerFilterL() |
|
170 { |
|
171 __GSLOGSTRING( "[CGSServerEngine] FlickerFilterL()" ); |
|
172 TInt value; |
|
173 User::LeaveIfError( iRepository->Get( KSettingsTvoutFlickerFilter, value ) ); |
|
174 SwitchValue( value ); |
|
175 return value; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CGSServerEngine::SetFlickerFilter |
|
180 // Set the value to the Central repository and initialize the driver. |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C void CGSServerEngine::SetFlickerFilterL( TInt aFlickerFilter ) |
|
184 { |
|
185 __GSLOGSTRING( "[CGSServerEngine] SetFlickerFilterL()" ); |
|
186 SwitchValue( aFlickerFilter ); |
|
187 TInt err = iRepository->Set( KSettingsTvoutFlickerFilter, aFlickerFilter ); |
|
188 User::LeaveIfError( err ); |
|
189 } |
|
190 |
|
191 // ---------------------------------------------------------------------------- |
|
192 // CGSServerEngine::SwitchValue |
|
193 // |
|
194 // Switching value from 1 to 0 and back |
|
195 // ---------------------------------------------------------------------------- |
|
196 // |
|
197 void CGSServerEngine::SwitchValue( TInt& aValue ) |
|
198 { |
|
199 __GSLOGSTRING( "[CGSServerEngine] SwitchValue()" ); |
|
200 switch( aValue ) |
|
201 { |
|
202 case KGSSettingOff: //0 |
|
203 aValue = KGSIndexOff; //1 |
|
204 break; |
|
205 case KGSSettingOn: //1 |
|
206 aValue = KGSIndexOn; //0 |
|
207 break; |
|
208 default: |
|
209 break; |
|
210 } |
|
211 } |
|
212 |
|
213 // ---------------------------------------------------------------------------- |
|
214 // CGSServerEngine::ConvertAspectRatio |
|
215 // |
|
216 // |
|
217 // ---------------------------------------------------------------------------- |
|
218 // |
|
219 void CGSServerEngine::ConvertAspectRatio( TInt& aValue ) |
|
220 { |
|
221 switch( aValue ) |
|
222 { |
|
223 case KGSTvAspectNormal: |
|
224 aValue = 1; |
|
225 break; |
|
226 case KGSTvAspectWide: |
|
227 aValue = 2; |
|
228 break; |
|
229 default: |
|
230 break; |
|
231 } |
|
232 } |
|
233 |
|
234 // ---------------------------------------------------------------------------- |
|
235 // CGSServerEngine::ConvertTvSystem |
|
236 // |
|
237 // |
|
238 // ---------------------------------------------------------------------------- |
|
239 // |
|
240 void CGSServerEngine::ConvertTvSystem( TInt& aValue ) |
|
241 { |
|
242 switch( aValue ) |
|
243 { |
|
244 case KGSTvSystemPal: |
|
245 aValue = 3; |
|
246 break; |
|
247 case KGSTvSystemPalm: |
|
248 aValue = 4; |
|
249 break; |
|
250 case KGSTvSystemNtsc: |
|
251 aValue = 1; |
|
252 default: |
|
253 break; |
|
254 } |
|
255 } |
|
256 |
|
257 // End of File |