Update contrib.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <kernel/kern_priv.h>
18 #include <graphics/surfacemanager.h>
19 #include "surfacemanager_dev.h"
24 DECLARE_EXTENSION_LDD()
26 return new DSurfaceManagerFactory;
29 static DSurfaceManager Manager;
33 DSurfaceManagerFactory::DSurfaceManagerFactory()
35 // Set version number for this device
36 iVersion=RSurfaceManagerDriver::VersionRequired();
41 TInt DSurfaceManagerFactory::Install()
43 return SetName(&RSurfaceManagerDriver::Name());
48 Called by the kernel's device driver framework to create a Logical Channel.
49 This is called in the context of the user thread (client) which requested the creation of a Logical Channel
50 (E.g. through a call to RBusLogicalChannel::DoCreate)
51 The thread is in a critical section.
53 @param aChannel Set to point to the created Logical Channel
55 @return KErrNone if successful, otherwise one of the other system wide error codes.
57 TInt DSurfaceManagerFactory::Create(DLogicalChannelBase*& aChannel)
59 aChannel=new DSurfaceManagerChannel();
68 Return the drivers capabilities.
69 Called in the response to an RDevice::GetCaps() request.
71 @param aDes User-side descriptor to write capabilities information into
73 void DSurfaceManagerFactory::GetCaps(TDes8& aDes) const
75 // Create a capabilities object
76 RSurfaceManagerDriver::TCaps caps;
77 caps.iVersion = iVersion;
78 // Write it back to user memory
79 Kern::InfoCopy(aDes,reinterpret_cast<TUint8*>(&caps),sizeof(caps));
84 DSurfaceManagerChannel::DSurfaceManagerChannel()
86 TRACE(Kern::Printf("SurfaceManagerChannel Creation");)
92 Called when the process owning the channel has died or closed the channel.
93 Calls the manager object to indicate that the process has closed a session so it
94 can cleanup the surfaces which are only owned by that process if it has no further connections.
96 DSurfaceManagerChannel::~DSurfaceManagerChannel()
98 Manager.RemoveConnection(iOwner);
103 Second stage constructor called by the kernel's device driver framework.
104 This is called in the context of the user thread (client) which requested the creation of a Logical Channel
105 (E.g. through a call to RBusLogicalChannel::DoCreate)
106 The thread is in a critical section.
108 @param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate
109 @param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate
110 @param aVer The version argument supplied by the client to RBusLogicalChannel::DoCreate
112 @return KErrNone if successful, otherwise one of the other system wide error codes.
114 TInt DSurfaceManagerChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
117 if (!Kern::QueryVersionSupported(RSurfaceManagerDriver::VersionRequired(),aVer))
118 return KErrNotSupported;
120 iOwner = &Kern::CurrentProcess();
121 TInt ret = Manager.AddConnection(iOwner);
131 Process a request on this logical channel.
133 @param aReqNo Request number:
134 ==KMaxTInt, a 'DoCancel' message
135 >=0, a 'DoControl' message with function number equal to iValue
136 <0, a 'DoRequest' message with function number equal to ~iValue
137 @param a1 First argument. For DoRequest requests this is a pointer to the TRequestStatus.
138 @param a2 Second argument. For DoRequest this is a pointer to the 2 actual TAny* arguments.
140 @return Result ignored by device driver framework for DoRequest requests.
142 TInt DSurfaceManagerChannel::Request(TInt aReqNo, TAny* a1, TAny* a2)
144 // Decode the message type and dispatch it to the relevent handler function...
145 // only using synchronous control messages
146 if (static_cast<TUint>(aReqNo) < static_cast<TUint>(KMaxTInt))
148 return DoControl(aReqNo, a1, a2);
151 return KErrNotSupported;
155 Process synchronous 'control' requests
157 TInt DSurfaceManagerChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
159 TRACE(Kern::Printf(">DSurfaceManagerChannel::DoControl fn=%d process = %u\n",aFunction, iOwner);)
164 case RSurfaceManagerDriver::EControlCreateSurface:
165 r = Manager.CreateSurface(reinterpret_cast<const TDesC8*>(a1), reinterpret_cast<TSurfaceId*>(a2));
168 case RSurfaceManagerDriver::EControlOpenSurface:
169 r = Manager.OpenSurface(reinterpret_cast<TSurfaceId*>(a1));
172 case RSurfaceManagerDriver::EControlCloseSurface:
173 r = Manager.CloseSurface(reinterpret_cast<TSurfaceId*>(a1));
176 case RSurfaceManagerDriver::EControlAccessSurfaceData:
177 r = Manager.MapSurface(reinterpret_cast<TSurfaceId*>(a1));
180 case RSurfaceManagerDriver::EControlSurfaceInfo:
181 r = Manager.SurfaceInfo(reinterpret_cast<TSurfaceId*>(a1), reinterpret_cast<TDes8*>(a2));
184 case RSurfaceManagerDriver::EControlCreateSurfaceEx:
185 r = Manager.CreateSurface(reinterpret_cast<RSurfaceManagerDriver::TDeviceParam*>(a1), (TInt)a2);
188 case RSurfaceManagerDriver::EControlSynchronizeCache:
189 r = Manager.SynchronizeCache(reinterpret_cast<RSurfaceManagerDriver::TDeviceParam*>(a1), (RSurfaceManager::TSyncOperation&)a2);
192 case RSurfaceManagerDriver::EControlGetSurfaceHint:
193 r = Manager.GetSurfaceHint(reinterpret_cast<TSurfaceId*>(a1), reinterpret_cast<RSurfaceManager::THintPair*>(a2));
196 case RSurfaceManagerDriver::EControlSetSurfaceHint:
197 r = Manager.SetSurfaceHint(reinterpret_cast<TSurfaceId*>(a1), reinterpret_cast<const RSurfaceManager::THintPair*>(a2));
200 case RSurfaceManagerDriver::EControlAddSurfaceHint:
201 r = Manager.AddSurfaceHint(reinterpret_cast<TSurfaceId*>(a1), reinterpret_cast<const RSurfaceManager::THintPair*>(a2));
203 case RSurfaceManagerDriver::EControlGetBufferOffset:
204 r = Manager.GetBufferOffset(reinterpret_cast<RSurfaceManagerDriver::TDeviceParam*>(a1),reinterpret_cast<TUint*>(a2));
206 case RSurfaceManagerDriver::EControlGetSurfaceManagerAttrib:
207 r = Manager.GetSurfaceManagerAttrib(reinterpret_cast<RSurfaceManager::TSurfaceManagerAttrib*>(a1),reinterpret_cast<TInt*>(a2));
210 r = KErrNotSupported;
213 TRACE(Kern::Printf("<SurfaceManagerChannel::DoControl result=%d\n",r);)
219 DECLARE_STANDARD_EXTENSION()
221 //called when kernel extension is loaded
222 //initialise the kernel extension
223 TRACE(Kern::Printf("<SurfaceManager Extension entry point\n");)