To start off, I just changed the memory model to CSPROPERTY_BUFFER_DRIVER
and made the following changes:
1. I made the following change to the AllocateBuffer function in my PDD
layer to just return the hardware frame buffer.
PVOID CCameraPdd::AllocateBuffer( ULONG ulModeType )
{
// Real PDD may want to save off this allocated pointer
// in an array.
// ULONG ulFrameSize = CS__DIBSIZE
(m_pCurrentFormat[ulModeType].VideoInfoHeader.bmiHeader);
// return RemoteLocalAlloc( LPTR, ulFrameSize );
return (m_pCameraHw->GetFrameBuffer());
}
2. In y PDD_FillBuffer, I do nothing and just return the size of the image.
I know I will have to use 2 or more frame buffers eventually to avoid memory
corruption issues, but I just wanted to test the concept first.
I am facing the following issues:
When the client calls IOCTL_CS_BUFFERS with the command CS_ENQUEUE, it
eventually results in a call to CPinDevice::EnqueueDescriptor which tries to
marshal the buffer. This results in a call to CeOpenCallerBuffer on the
buffer which fails with E_ACCESSDENIED. I noticed that the PDD portion is
allocating the buffer using HalAllocateCommonBuffer() and then it assigns a
virtual address to it using VirtualAlloc(NULL,dwSize,
MEM_RESERVE,PAGE_NOACCESS). I changed the access protection to PAGE_READONLY
but CeOpenCallerBuffer still fails.
Also, during CS_ENQUEUE, there is no call to the PDD layer to notify the
driver that it has been granted ownership of the buffer. If I allocate 2 or
more buffers in my PDD driver, how do I know when to switch frame buffers?
Any help on the above is appreciated. Thanks!