1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicshwdrivers/surfacemgr/src/surfacemanagerdriver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,226 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +#include <kernel/kern_priv.h>
1.21 +#include <graphics/surfacemanager.h>
1.22 +#include "surfacemanager_dev.h"
1.23 +
1.24 +
1.25 +
1.26 +
1.27 +DECLARE_EXTENSION_LDD()
1.28 + {
1.29 + return new DSurfaceManagerFactory;
1.30 + }
1.31 +
1.32 +static DSurfaceManager Manager;
1.33 +
1.34 +
1.35 +
1.36 +DSurfaceManagerFactory::DSurfaceManagerFactory()
1.37 + {
1.38 + // Set version number for this device
1.39 + iVersion=RSurfaceManagerDriver::VersionRequired();
1.40 +
1.41 + iParseMask=0;
1.42 + }
1.43 +
1.44 +TInt DSurfaceManagerFactory::Install()
1.45 + {
1.46 + return SetName(&RSurfaceManagerDriver::Name());
1.47 + }
1.48 +
1.49 +
1.50 +/**
1.51 + Called by the kernel's device driver framework to create a Logical Channel.
1.52 + This is called in the context of the user thread (client) which requested the creation of a Logical Channel
1.53 + (E.g. through a call to RBusLogicalChannel::DoCreate)
1.54 + The thread is in a critical section.
1.55 +
1.56 + @param aChannel Set to point to the created Logical Channel
1.57 +
1.58 + @return KErrNone if successful, otherwise one of the other system wide error codes.
1.59 +*/
1.60 +TInt DSurfaceManagerFactory::Create(DLogicalChannelBase*& aChannel)
1.61 + {
1.62 + aChannel=new DSurfaceManagerChannel();
1.63 + if(!aChannel)
1.64 + return KErrNoMemory;
1.65 + return KErrNone;
1.66 + }
1.67 +
1.68 +
1.69 +
1.70 +/**
1.71 + Return the drivers capabilities.
1.72 + Called in the response to an RDevice::GetCaps() request.
1.73 +
1.74 + @param aDes User-side descriptor to write capabilities information into
1.75 +*/
1.76 +void DSurfaceManagerFactory::GetCaps(TDes8& aDes) const
1.77 + {
1.78 + // Create a capabilities object
1.79 + RSurfaceManagerDriver::TCaps caps;
1.80 + caps.iVersion = iVersion;
1.81 + // Write it back to user memory
1.82 + Kern::InfoCopy(aDes,reinterpret_cast<TUint8*>(&caps),sizeof(caps));
1.83 + }
1.84 +
1.85 +
1.86 +
1.87 +DSurfaceManagerChannel::DSurfaceManagerChannel()
1.88 + {
1.89 + TRACE(Kern::Printf("SurfaceManagerChannel Creation");)
1.90 + }
1.91 +
1.92 +
1.93 +/**
1.94 +Channel destructor.
1.95 +Called when the process owning the channel has died or closed the channel.
1.96 +Calls the manager object to indicate that the process has closed a session so it
1.97 +can cleanup the surfaces which are only owned by that process if it has no further connections.
1.98 +*/
1.99 +DSurfaceManagerChannel::~DSurfaceManagerChannel()
1.100 + {
1.101 + Manager.RemoveConnection(iOwner);
1.102 + }
1.103 +
1.104 +
1.105 +/**
1.106 + Second stage constructor called by the kernel's device driver framework.
1.107 + This is called in the context of the user thread (client) which requested the creation of a Logical Channel
1.108 + (E.g. through a call to RBusLogicalChannel::DoCreate)
1.109 + The thread is in a critical section.
1.110 +
1.111 + @param aUnit The unit argument supplied by the client to RBusLogicalChannel::DoCreate
1.112 + @param aInfo The info argument supplied by the client to RBusLogicalChannel::DoCreate
1.113 + @param aVer The version argument supplied by the client to RBusLogicalChannel::DoCreate
1.114 +
1.115 + @return KErrNone if successful, otherwise one of the other system wide error codes.
1.116 +*/
1.117 +TInt DSurfaceManagerChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
1.118 + {
1.119 + // Check version
1.120 + if (!Kern::QueryVersionSupported(RSurfaceManagerDriver::VersionRequired(),aVer))
1.121 + return KErrNotSupported;
1.122 +
1.123 + iOwner = &Kern::CurrentProcess();
1.124 + TInt ret = Manager.AddConnection(iOwner);
1.125 + if (ret != KErrNone)
1.126 + iOwner = NULL;
1.127 +
1.128 + return ret;
1.129 + }
1.130 +
1.131 +
1.132 +
1.133 +/**
1.134 + Process a request on this logical channel.
1.135 +
1.136 + @param aReqNo Request number:
1.137 + ==KMaxTInt, a 'DoCancel' message
1.138 + >=0, a 'DoControl' message with function number equal to iValue
1.139 + <0, a 'DoRequest' message with function number equal to ~iValue
1.140 + @param a1 First argument. For DoRequest requests this is a pointer to the TRequestStatus.
1.141 + @param a2 Second argument. For DoRequest this is a pointer to the 2 actual TAny* arguments.
1.142 +
1.143 + @return Result ignored by device driver framework for DoRequest requests.
1.144 +*/
1.145 +TInt DSurfaceManagerChannel::Request(TInt aReqNo, TAny* a1, TAny* a2)
1.146 + {
1.147 + // Decode the message type and dispatch it to the relevent handler function...
1.148 + // only using synchronous control messages
1.149 + if (static_cast<TUint>(aReqNo) < static_cast<TUint>(KMaxTInt))
1.150 + {
1.151 + return DoControl(aReqNo, a1, a2);
1.152 + }
1.153 +
1.154 + return KErrNotSupported;
1.155 + }
1.156 +
1.157 +/**
1.158 + Process synchronous 'control' requests
1.159 +*/
1.160 +TInt DSurfaceManagerChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
1.161 + {
1.162 + TRACE(Kern::Printf(">DSurfaceManagerChannel::DoControl fn=%d process = %u\n",aFunction, iOwner);)
1.163 +
1.164 + TInt r;
1.165 + switch(aFunction)
1.166 + {
1.167 + case RSurfaceManagerDriver::EControlCreateSurface:
1.168 + r = Manager.CreateSurface(reinterpret_cast<const TDesC8*>(a1), reinterpret_cast<TSurfaceId*>(a2));
1.169 + break;
1.170 +
1.171 + case RSurfaceManagerDriver::EControlOpenSurface:
1.172 + r = Manager.OpenSurface(reinterpret_cast<TSurfaceId*>(a1));
1.173 + break;
1.174 +
1.175 + case RSurfaceManagerDriver::EControlCloseSurface:
1.176 + r = Manager.CloseSurface(reinterpret_cast<TSurfaceId*>(a1));
1.177 + break;
1.178 +
1.179 + case RSurfaceManagerDriver::EControlAccessSurfaceData:
1.180 + r = Manager.MapSurface(reinterpret_cast<TSurfaceId*>(a1));
1.181 + break;
1.182 +
1.183 + case RSurfaceManagerDriver::EControlSurfaceInfo:
1.184 + r = Manager.SurfaceInfo(reinterpret_cast<TSurfaceId*>(a1), reinterpret_cast<TDes8*>(a2));
1.185 + break;
1.186 +
1.187 + case RSurfaceManagerDriver::EControlCreateSurfaceEx:
1.188 + r = Manager.CreateSurface(reinterpret_cast<RSurfaceManagerDriver::TDeviceParam*>(a1), (TInt)a2);
1.189 + break;
1.190 +
1.191 + case RSurfaceManagerDriver::EControlSynchronizeCache:
1.192 + r = Manager.SynchronizeCache(reinterpret_cast<RSurfaceManagerDriver::TDeviceParam*>(a1), (RSurfaceManager::TSyncOperation&)a2);
1.193 + break;
1.194 +
1.195 + case RSurfaceManagerDriver::EControlGetSurfaceHint:
1.196 + r = Manager.GetSurfaceHint(reinterpret_cast<TSurfaceId*>(a1), reinterpret_cast<RSurfaceManager::THintPair*>(a2));
1.197 + break;
1.198 +
1.199 + case RSurfaceManagerDriver::EControlSetSurfaceHint:
1.200 + r = Manager.SetSurfaceHint(reinterpret_cast<TSurfaceId*>(a1), reinterpret_cast<const RSurfaceManager::THintPair*>(a2));
1.201 + break;
1.202 +
1.203 + case RSurfaceManagerDriver::EControlAddSurfaceHint:
1.204 + r = Manager.AddSurfaceHint(reinterpret_cast<TSurfaceId*>(a1), reinterpret_cast<const RSurfaceManager::THintPair*>(a2));
1.205 + break;
1.206 + case RSurfaceManagerDriver::EControlGetBufferOffset:
1.207 + r = Manager.GetBufferOffset(reinterpret_cast<RSurfaceManagerDriver::TDeviceParam*>(a1),reinterpret_cast<TUint*>(a2));
1.208 + break;
1.209 + case RSurfaceManagerDriver::EControlGetSurfaceManagerAttrib:
1.210 + r = Manager.GetSurfaceManagerAttrib(reinterpret_cast<RSurfaceManager::TSurfaceManagerAttrib*>(a1),reinterpret_cast<TInt*>(a2));
1.211 + break;
1.212 + default:
1.213 + r = KErrNotSupported;
1.214 + break;
1.215 + }
1.216 + TRACE(Kern::Printf("<SurfaceManagerChannel::DoControl result=%d\n",r);)
1.217 + return r;
1.218 + }
1.219 +
1.220 +
1.221 +
1.222 +DECLARE_STANDARD_EXTENSION()
1.223 + {
1.224 + //called when kernel extension is loaded
1.225 + //initialise the kernel extension
1.226 + TRACE(Kern::Printf("<SurfaceManager Extension entry point\n");)
1.227 + return KErrNone;
1.228 + }
1.229 +