VOID STREAMAPI VideoReceiveCtrlPacket( IN PHW_STREAM_REQUEST_BLOCK pSrb ) { PHW_DEVICE_EXTENSION pHwDevExt = ((PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension); PSTREAMEX pStrmEx = (PSTREAMEX)pSrb->StreamObject->HwStreamExtension; int StreamNumber = pStrmEx->pStreamObject->StreamNumber; BOOL Busy; // // make sure we have a device extension and are at passive level // DEBUG_ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); DEBUG_ASSERT(pHwDevExt!=NULL); DbgLogTrace(("TestCap: Receiving Stream Control SRB %p, %x\n", pSrb, pSrb->Command)); // // If we're already processing an SRB, add it to the queue // Busy = AddToListIfBusy ( pSrb, &pHwDevExt->AdapterSpinLock, &pHwDevExt->ProcessingControlSRB [StreamNumber], &pHwDevExt->StreamControlSRBList[StreamNumber]); if (Busy) { return; } while (TRUE) { // // Default to success // pSrb->Status = STATUS_SUCCESS; // // determine the type of packet. // switch (pSrb->Command) { case SRB_PROPOSE_DATA_FORMAT: DbgLogInfo(("TestCap: Receiving SRB_PROPOSE_DATA_FORMAT SRB %p, StreamNumber= %d\n", pSrb, StreamNumber)); if (!(AdapterVerifyFormat ( pSrb->CommandData.OpenFormat, pSrb->StreamObject->StreamNumber))) { pSrb->Status = STATUS_NO_MATCH; DbgLogInfo(("TestCap: SRB_PROPOSE_DATA_FORMAT FAILED\n")); } // KS support for dynamic format changes is BROKEN right now, // so we prevent these from happening by saying they ALL fail. // If this is ever fixed, the next line must be removed. pSrb->Status = STATUS_NO_MATCH; // prevent dynamic format changes break; case SRB_SET_DATA_FORMAT: DbgLogInfo(("TestCap: SRB_SET_DATA_FORMAT\n")); if (!(AdapterVerifyFormat ( pSrb->CommandData.OpenFormat, pSrb->StreamObject->StreamNumber))) { pSrb->Status = STATUS_NO_MATCH; DbgLogInfo(("TestCap: SRB_SET_DATA_FORMAT FAILED\n")); } else { VideoSetFormat (pSrb); DbgLogInfo(("TestCap: SRB_SET_DATA_FORMAT SUCCEEDED\n")); } break; case SRB_GET_DATA_FORMAT: DbgLogInfo(("TestCap: SRB_GET_DATA_FORMAT\n")); pSrb->Status = STATUS_NOT_IMPLEMENTED; break; case SRB_SET_STREAM_STATE: VideoSetState(pSrb); break; case SRB_GET_STREAM_STATE: VideoGetState(pSrb); break; case SRB_GET_STREAM_PROPERTY: VideoGetProperty(pSrb); break; case SRB_SET_STREAM_PROPERTY: VideoSetProperty(pSrb); break; case SRB_INDICATE_MASTER_CLOCK: // // Assigns a clock to a stream // VideoIndicateMasterClock (pSrb); break; default: // // invalid / unsupported command. Fail it as such // TRAP; pSrb->Status = STATUS_NOT_IMPLEMENTED; } CompleteStreamSRB (pSrb); // // See if there's anything else on the queue // Busy = RemoveFromListIfAvailable ( &pSrb, &pHwDevExt->AdapterSpinLock, &pHwDevExt->ProcessingControlSRB [StreamNumber], &pHwDevExt->StreamControlSRBList[StreamNumber]); if (!Busy) { break; } } }
VOID STREAMAPI AdapterOpenStream ( PHW_STREAM_REQUEST_BLOCK pSrb ) { // // the stream extension structure is allocated by the stream class driver // PSTREAMEX pStrmEx = (PSTREAMEX)pSrb->StreamObject->HwStreamExtension; PHW_DEVICE_EXTENSION pHwDevExt = ((PHW_DEVICE_EXTENSION)pSrb->HwDeviceExtension); int StreamNumber = pSrb->StreamObject->StreamNumber; PKSDATAFORMAT pKSDataFormat = pSrb->CommandData.OpenFormat; RtlZeroMemory(pStrmEx, sizeof(STREAMEX)); DbgLogInfo(("TestCap: ------- ADAPTEROPENSTREAM ------- StreamNumber=%d\n", StreamNumber)); // // check that the stream index requested isn't too high // or that the maximum number of instances hasn't been exceeded // if (StreamNumber >= DRIVER_STREAM_COUNT || StreamNumber < 0) { pSrb->Status = STATUS_INVALID_PARAMETER; return; } // // Check that we haven't exceeded the instance count for this stream // if (pHwDevExt->ActualInstances[StreamNumber] >= Streams[StreamNumber].hwStreamInfo.NumberOfPossibleInstances) { pSrb->Status = STATUS_INVALID_PARAMETER; return; } // // Check the validity of the format being requested // if (!AdapterVerifyFormat (pKSDataFormat, StreamNumber)) { pSrb->Status = STATUS_INVALID_PARAMETER; return; } // // And set the format for the stream // if (!VideoSetFormat (pSrb)) { return; } ASSERT (pHwDevExt->pStrmEx [StreamNumber] == NULL); // Maintain an array of all the StreamEx structures in the HwDevExt // so that we can cancel IRPs from any stream pHwDevExt->pStrmEx [StreamNumber] = (PSTREAMX) pStrmEx; // Set up pointers to the handlers for the stream data and control handlers pSrb->StreamObject->ReceiveDataPacket = (PVOID) Streams[StreamNumber].hwStreamObject.ReceiveDataPacket; pSrb->StreamObject->ReceiveControlPacket = (PVOID) Streams[StreamNumber].hwStreamObject.ReceiveControlPacket; // // The DMA flag must be set when the device will be performing DMA directly // to the data buffer addresses passed in to the ReceiceDataPacket routines. // pSrb->StreamObject->Dma = Streams[StreamNumber].hwStreamObject.Dma; // // The PIO flag must be set when the mini driver will be accessing the data // buffers passed in using logical addressing // pSrb->StreamObject->Pio = Streams[StreamNumber].hwStreamObject.Pio; // // How many extra bytes will be passed up from the driver for each frame? // pSrb->StreamObject->StreamHeaderMediaSpecific = Streams[StreamNumber].hwStreamObject.StreamHeaderMediaSpecific; pSrb->StreamObject->StreamHeaderWorkspace = Streams[StreamNumber].hwStreamObject.StreamHeaderWorkspace; // // Indicate the clock support available on this stream // pSrb->StreamObject->HwClockObject = Streams[StreamNumber].hwStreamObject.HwClockObject; // // Increment the instance count on this stream // pHwDevExt->ActualInstances[StreamNumber]++; // Retain a private copy of the HwDevExt and StreamObject in the stream extension // so we can use a timer pStrmEx->pHwDevExt = pHwDevExt; // For timer use pStrmEx->pStreamObject = pSrb->StreamObject; // For timer use // Initialize the compression settings // These may have been changed from the default values in the HwDevExt // before the stream was opened pStrmEx->CompressionSettings.CompressionKeyFrameRate = pHwDevExt->CompressionSettings.CompressionKeyFrameRate; pStrmEx->CompressionSettings.CompressionPFramesPerKeyFrame = pHwDevExt->CompressionSettings.CompressionPFramesPerKeyFrame; pStrmEx->CompressionSettings.CompressionQuality = pHwDevExt->CompressionSettings.CompressionQuality; // Init VideoControl properties pStrmEx->VideoControlMode = pHwDevExt->VideoControlMode; // Init VBI variables pStrmEx->SentVBIInfoHeader = 0; DbgLogInfo(("TestCap: AdapterOpenStream Exit\n")); }