Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1558 lines
57 KiB

  1. //===========================================================================
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1996 - 2000 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //===========================================================================
  11. /*++
  12. Module Name:
  13. CapProp.c
  14. Abstract:
  15. Stream class based WDM driver for 1934 Desktop Camera.
  16. This file contains code to handle the video and camera control properties.
  17. Author:
  18. Yee J. Wu 9-Sep-97
  19. Environment:
  20. Kernel mode only
  21. Revision History:
  22. Yee J. Wu 16-Nov-00
  23. Make getting, advertising, and setting device properties more generic
  24. by querying feature from the device directly instead of static settings
  25. based on the vendor. The default and initial current settings will be
  26. read from registry (from the INF). The current setting will continue
  27. to be updated and used thereafter. For device that does not have its INF
  28. section, mid-range will be used as its default and initial settings.
  29. --*/
  30. #include "strmini.h"
  31. #include "ksmedia.h"
  32. #include "1394.h"
  33. #include "wdm.h" // for DbgBreakPoint() defined in dbg.h
  34. #include "dbg.h"
  35. #include "dcamdef.h"
  36. #include "dcampkt.h"
  37. #include "capprop.h" // Video and camera property function prototype
  38. #include "PropData.h" // Generic device properties that are readonly
  39. //
  40. // Registry subky and values wide character strings.
  41. //
  42. WCHAR wszSettings[] = L"Settings";
  43. WCHAR wszVModeInq0[] = L"VModeInq0";
  44. WCHAR wszBrightness[] = L"Brightness";
  45. WCHAR wszHue[] = L"Hue";
  46. WCHAR wszSaturation[] = L"Saturation";
  47. WCHAR wszSharpness[] = L"Sharpness";
  48. WCHAR wszWhiteBalance[] = L"WhiteBalance";
  49. WCHAR wszZoom[] = L"Zoom";
  50. WCHAR wszFocus[] = L"Focus";
  51. WCHAR wszBrightnessDef[] = L"BrightnessDef";
  52. WCHAR wszHueDef[] = L"HueDef";
  53. WCHAR wszSaturationDef[] = L"SaturationDef";
  54. WCHAR wszSharpnessDef[] = L"SharpnessDef";
  55. WCHAR wszWhiteBalanceDef[] = L"WhiteBalanceDef";
  56. WCHAR wszZoomDef[] = L"ZoomDef";
  57. WCHAR wszFocusDef[] = L"FocusDef";
  58. NTSTATUS
  59. DCamGetProperty(
  60. IN PIRB pIrb,
  61. PDCAM_EXTENSION pDevExt,
  62. ULONG ulFieldOffset,
  63. LONG * plValue,
  64. ULONG * pulCapability,
  65. ULONG * pulFlags,
  66. DCamRegArea * pFeature
  67. )
  68. /*
  69. Get a device property from its register. Return the capabilites and current settings.
  70. */
  71. {
  72. NTSTATUS status, StatusWait;
  73. // Make sure that device support this feature.
  74. if(pFeature->Feature.PresenceInq == 0) {
  75. DbgMsg1(("\'OffSet:%d not supported!\n", ulFieldOffset));
  76. return STATUS_NOT_SUPPORTED;
  77. }
  78. // Serialize read/write to the device register
  79. StatusWait = KeWaitForSingleObject( &pDevExt->hMutexProperty, Executive, KernelMode, FALSE, 0 );
  80. *pulCapability = 0;
  81. if (pFeature->Feature.AutoMode)
  82. *pulCapability |= KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO; // or == KSPROPERTY_CAMERACONTROL_FLAGS_AUTO
  83. if (pFeature->Feature.ManualMode)
  84. *pulCapability |= KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  85. pDevExt->RegArea.AsULONG = 0;
  86. status = DCamReadRegister(pIrb, pDevExt, ulFieldOffset, &(pDevExt->RegArea.AsULONG));
  87. if(NT_SUCCESS(status)) {
  88. pDevExt->RegArea.AsULONG = bswap(pDevExt->RegArea.AsULONG);
  89. DbgMsg1(("\'GetProperty: CurrentSettings: Offset:%d; %x; Pres:%d;OnePush:%d;OnOff:%d;Auto:%d;Value:%d\n",
  90. ulFieldOffset,
  91. pDevExt->RegArea.AsULONG,
  92. pDevExt->RegArea.Brightness.PresenceInq,
  93. pDevExt->RegArea.Brightness.OnePush,
  94. pDevExt->RegArea.Brightness.OnOff,
  95. pDevExt->RegArea.Brightness.AutoMode,
  96. pDevExt->RegArea.Brightness.Value
  97. ));
  98. *plValue = (LONG) pDevExt->RegArea.Brightness.Value;
  99. // These only valid if it has these capabilities.
  100. if (pDevExt->RegArea.Brightness.AutoMode)
  101. *pulFlags = KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO;
  102. else
  103. *pulFlags = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  104. } else {
  105. ERROR_LOG(("\'DCamGetProperty: Failed %x to read setting. Offset:%x\n", status, ulFieldOffset));
  106. status = STATUS_UNSUCCESSFUL;
  107. }
  108. KeReleaseMutex(&pDevExt->hMutexProperty, FALSE);
  109. return status;
  110. }
  111. NTSTATUS
  112. DCamSetProperty(
  113. IN PIRB pIrb,
  114. PDCAM_EXTENSION pDevExt,
  115. ULONG ulFieldOffset,
  116. ULONG ulFlags,
  117. LONG lValue,
  118. DCamRegArea * pFeature,
  119. DCamRegArea * pCachedRegArea
  120. )
  121. /*
  122. For a supported device, set to a new setting.
  123. */
  124. {
  125. NTSTATUS status, StatusWait;
  126. LONG lRetries = MAX_READ_REG_RETRIES;
  127. LARGE_INTEGER stableTime;
  128. // Make sure that device support this feature.
  129. if(pFeature->Feature.PresenceInq == 0) {
  130. DbgMsg1(("\'OffSet:%d not supported!\n", ulFieldOffset));
  131. return STATUS_NOT_SUPPORTED;
  132. }
  133. // Validate the supported range
  134. if((LONG) pFeature->Feature.MAX_Value < lValue || lValue < (LONG) pFeature->Feature.MIN_Value) {
  135. ERROR_LOG(("\'Invalid value:%d for supported range (%d, %d)\n", lValue, pFeature->Feature.MIN_Value, pFeature->Feature.MAX_Value));
  136. return STATUS_INVALID_PARAMETER;
  137. }
  138. // Serialize read/write to the register
  139. StatusWait = KeWaitForSingleObject( &pDevExt->hMutexProperty, Executive, KernelMode, FALSE, 0 );
  140. // Read the current setting of this property
  141. pDevExt->RegArea.AsULONG = 0;
  142. do {
  143. status = DCamReadRegister(pIrb, pDevExt, ulFieldOffset, &(pDevExt->RegArea.AsULONG));
  144. if (!status) {
  145. pDevExt->RegArea.AsULONG = bswap(pDevExt->RegArea.AsULONG);
  146. DbgMsg3(("\'SetProperty: Current: %x: Pres:%d;OnePush:%d;OnOff:%d;Auto:%d;Value:%d\n",
  147. pDevExt->RegArea.AsULONG,
  148. pDevExt->RegArea.Brightness.PresenceInq,
  149. pDevExt->RegArea.Brightness.OnePush,
  150. pDevExt->RegArea.Brightness.OnOff,
  151. pDevExt->RegArea.Brightness.AutoMode,
  152. pDevExt->RegArea.Brightness.Value
  153. ));
  154. // This feature might be in the transition (such as zoom or focus),
  155. // it might return pDevExt->RegArea.Brightness.PresenceInq == 0.
  156. if(pDevExt->RegArea.Brightness.PresenceInq == 1)
  157. break;
  158. else {
  159. if(lRetries > 1) {
  160. stableTime.LowPart = DCAM_REG_STABLE_DELAY;
  161. stableTime.HighPart = -1;
  162. KeDelayExecutionThread(KernelMode, TRUE, &stableTime);
  163. ERROR_LOG(("\'DCamSetProperty: delay, and try again...\n"));
  164. };
  165. }
  166. } else {
  167. // No need to retry if we failed to read.
  168. break;
  169. }
  170. lRetries--;
  171. } while (lRetries > 0);
  172. if(status || lRetries == 0) {
  173. KeReleaseMutex(&pDevExt->hMutexProperty, FALSE);
  174. ERROR_LOG(("\'DCamSetProperty: Failed! ST:%x; exceeded retried while pres is still 0\n", status));
  175. return STATUS_UNSUCCESSFUL;
  176. }
  177. pDevExt->RegArea.Brightness.PresenceInq = 1; // Should be present.
  178. if((ulFlags & KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO) == KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO) {
  179. pDevExt->RegArea.Brightness.AutoMode = 1;
  180. // When Auto is set to 1, Value field is ignored.
  181. } else {
  182. pDevExt->RegArea.Brightness.AutoMode = 0;
  183. // special case for white balance
  184. if(FIELDOFFSET(CAMERA_REGISTER_MAP, WhiteBalance) == ulFieldOffset) {
  185. pDevExt->RegArea.WhiteBalance.UValue = pDevExt->RegArea.WhiteBalance.VValue = lValue;
  186. } else
  187. pDevExt->RegArea.Brightness.Value = lValue;
  188. }
  189. DbgMsg2(("\'SetProperty: NewSetting: Offset:%d; %x; Pres:%d;OnePush:%d;OnOff:%d;Auto:%d;Value:%d\n",
  190. ulFieldOffset,
  191. pDevExt->RegArea.AsULONG,
  192. pDevExt->RegArea.Brightness.PresenceInq,
  193. pDevExt->RegArea.Brightness.OnePush,
  194. pDevExt->RegArea.Brightness.OnOff,
  195. pDevExt->RegArea.Brightness.AutoMode,
  196. pDevExt->RegArea.Brightness.Value
  197. ));
  198. pDevExt->RegArea.AsULONG = bswap(pDevExt->RegArea.AsULONG);
  199. status = DCamWriteRegister(pIrb, pDevExt, ulFieldOffset, pDevExt->RegArea.AsULONG);
  200. if(status) {
  201. ERROR_LOG(("\'DCamGetProperty: failed with status=0x%x\n", status));
  202. } else {
  203. // Update the cached setting (saved in the device extension)
  204. // These cached values will be save to registry as the persisted values for these properties.
  205. if(pCachedRegArea) {
  206. // WhiteBalance is an exception
  207. if(FIELDOFFSET(CAMERA_REGISTER_MAP, WhiteBalance) == ulFieldOffset) {
  208. pCachedRegArea->WhiteBalance.UValue = pCachedRegArea->WhiteBalance.VValue = lValue;
  209. } else
  210. pCachedRegArea->Brightness.Value = lValue;
  211. // AutoMode is the 7th bit for all the properties used here. (we do not use TRIGGER_MODE)
  212. pCachedRegArea->Brightness.AutoMode = ((ulFlags & KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO) == KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO);
  213. }
  214. #if DBG
  215. // Verify that data were written as expected.
  216. pDevExt->RegAreaVerify.AsULONG = 0;
  217. status = DCamReadRegister(pIrb, pDevExt, ulFieldOffset, &(pDevExt->RegAreaVerify.AsULONG));
  218. if (!status) {
  219. // bswap so we can compare.
  220. pDevExt->RegArea.AsULONG = bswap(pDevExt->RegArea.AsULONG);
  221. pDevExt->RegAreaVerify.AsULONG = bswap(pDevExt->RegAreaVerify.AsULONG);
  222. DbgMsg2(("\'SetProperty: VerifySetting; Offset:%d; %x; Pres:%d;OnePush:%d;OnOff:%d;Auto:%d;Value:%d\n\n",
  223. ulFieldOffset,
  224. pDevExt->RegAreaVerify.AsULONG,
  225. pDevExt->RegAreaVerify.Brightness.PresenceInq,
  226. pDevExt->RegAreaVerify.Brightness.OnePush,
  227. pDevExt->RegAreaVerify.Brightness.OnOff,
  228. pDevExt->RegAreaVerify.Brightness.AutoMode,
  229. pDevExt->RegAreaVerify.Brightness.Value
  230. ));
  231. ASSERT(pDevExt->RegArea.Brightness.PresenceInq == pDevExt->RegAreaVerify.Brightness.PresenceInq);
  232. ASSERT(pDevExt->RegArea.Brightness.OnePush == pDevExt->RegAreaVerify.Brightness.OnePush);
  233. ASSERT(pDevExt->RegArea.Brightness.OnOff == pDevExt->RegAreaVerify.Brightness.OnOff);
  234. ASSERT(pDevExt->RegArea.Brightness.AutoMode == pDevExt->RegAreaVerify.Brightness.AutoMode);
  235. // If not auto mode, Value must match!
  236. ASSERT( pDevExt->RegArea.Brightness.Value == pDevExt->RegAreaVerify.Brightness.Value ||
  237. (pDevExt->RegArea.Brightness.Value != pDevExt->RegAreaVerify.Brightness.Value && pDevExt->RegArea.Brightness.AutoMode == 1));
  238. }
  239. #endif
  240. }
  241. KeReleaseMutex(&pDevExt->hMutexProperty, FALSE);
  242. return status;
  243. }
  244. /*
  245. ** AdapterGetVideoProcAmpProperty ()
  246. **
  247. ** Handles Set operations on the VideoProcAmp property set.
  248. ** Testcap uses this for demo purposes only.
  249. **
  250. ** Arguments:
  251. **
  252. ** pSRB -
  253. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  254. **
  255. ** Returns:
  256. **
  257. ** Side Effects: none
  258. */
  259. VOID
  260. AdapterGetVideoProcAmpProperty(
  261. PHW_STREAM_REQUEST_BLOCK pSrb
  262. )
  263. {
  264. NTSTATUS status;
  265. PDCAM_EXTENSION pDevExt = (PDCAM_EXTENSION) pSrb->HwDeviceExtension;
  266. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  267. PKSPROPERTY_VIDEOPROCAMP_S pS = (PKSPROPERTY_VIDEOPROCAMP_S) pSPD->PropertyInfo; // pointer to the data
  268. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEOPROCAMP_S));
  269. switch (pSPD->Property->Id) {
  270. case KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS:
  271. status = DCamGetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Brightness), &pS->Value, &pS->Capabilities, &pS->Flags, &pDevExt->DevProperty[ENUM_BRIGHTNESS].Feature);
  272. break;
  273. case KSPROPERTY_VIDEOPROCAMP_SHARPNESS:
  274. status = DCamGetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Sharpness), &pS->Value, &pS->Capabilities, &pS->Flags, &pDevExt->DevProperty[ENUM_SHARPNESS].Feature);
  275. break;
  276. case KSPROPERTY_VIDEOPROCAMP_HUE:
  277. status = DCamGetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Hue), &pS->Value, &pS->Capabilities, &pS->Flags, &pDevExt->DevProperty[ENUM_HUE].Feature);
  278. break;
  279. case KSPROPERTY_VIDEOPROCAMP_SATURATION:
  280. status = DCamGetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Saturation), &pS->Value, &pS->Capabilities, &pS->Flags, &pDevExt->DevProperty[ENUM_SATURATION].Feature);
  281. break;
  282. case KSPROPERTY_VIDEOPROCAMP_WHITEBALANCE:
  283. status = DCamGetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, WhiteBalance), &pS->Value, &pS->Capabilities, &pS->Flags, &pDevExt->DevProperty[ENUM_WHITEBALANCE].Feature);
  284. break;
  285. default:
  286. DbgMsg2(("\'AdapterGetVideoProcAmpProperty, Id (%x)not supported.\n", pSPD->Property->Id));
  287. ASSERT(FALSE);
  288. status = STATUS_NOT_IMPLEMENTED;
  289. break;
  290. }
  291. pSrb->Status = status;
  292. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_VIDEOPROCAMP_S);
  293. }
  294. /*
  295. ** AdapterGetCameraControlProperty ()
  296. **
  297. ** Handles Set operations on the VideoProcAmp property set.
  298. ** Testcap uses this for demo purposes only.
  299. **
  300. ** Arguments:
  301. **
  302. ** pSRB -
  303. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  304. **
  305. ** Returns:
  306. **
  307. ** Side Effects: none
  308. */
  309. VOID
  310. AdapterGetCameraControlProperty(
  311. PHW_STREAM_REQUEST_BLOCK pSrb
  312. )
  313. {
  314. NTSTATUS status;
  315. PDCAM_EXTENSION pDevExt = (PDCAM_EXTENSION) pSrb->HwDeviceExtension;
  316. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  317. PKSPROPERTY_CAMERACONTROL_S pS = (PKSPROPERTY_CAMERACONTROL_S) pSPD->PropertyInfo; // pointer to the data
  318. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_CAMERACONTROL_S));
  319. switch (pSPD->Property->Id) {
  320. case KSPROPERTY_CAMERACONTROL_FOCUS:
  321. status = DCamGetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Focus), &pS->Value, &pS->Capabilities, &pS->Flags, &pDevExt->DevProperty[ENUM_FOCUS].Feature);
  322. break;
  323. case KSPROPERTY_CAMERACONTROL_ZOOM:
  324. status = DCamGetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Zoom), &pS->Value, &pS->Capabilities, &pS->Flags, &pDevExt->DevProperty[ENUM_ZOOM].Feature);
  325. break;
  326. default:
  327. DbgMsg2(("\'AdapterGetCameraControlProperty, Id (%x)not supported.\n", pSPD->Property->Id));
  328. ASSERT(FALSE);
  329. status = STATUS_NOT_IMPLEMENTED;
  330. break;
  331. }
  332. pSrb->Status = status;
  333. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_CAMERACONTROL_S);
  334. }
  335. /*
  336. ** AdapterGetProperty ()
  337. **
  338. ** Handles Get operations for all adapter properties.
  339. **
  340. ** Arguments:
  341. **
  342. ** pSRB -
  343. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  344. **
  345. ** Returns:
  346. **
  347. ** Side Effects: none
  348. */
  349. VOID
  350. STREAMAPI
  351. AdapterGetProperty(
  352. PHW_STREAM_REQUEST_BLOCK pSrb
  353. )
  354. {
  355. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  356. if (IsEqualGUID(&PROPSETID_VIDCAP_VIDEOPROCAMP, &pSPD->Property->Set)) {
  357. AdapterGetVideoProcAmpProperty (pSrb);
  358. } else if (IsEqualGUID(&PROPSETID_VIDCAP_CAMERACONTROL, &pSPD->Property->Set)) {
  359. AdapterGetCameraControlProperty (pSrb);
  360. } else {
  361. //
  362. // We should never get here
  363. //
  364. ASSERT(FALSE);
  365. }
  366. }
  367. /*
  368. ** AdapterSetVideoProcAmpProperty ()
  369. **
  370. ** Handles Set operations on the VideoProcAmp property set.
  371. ** Testcap uses this for demo purposes only.
  372. **
  373. ** Arguments:
  374. **
  375. ** pSRB -
  376. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  377. **
  378. ** Returns:
  379. **
  380. ** Side Effects: none
  381. */
  382. VOID
  383. AdapterSetVideoProcAmpProperty(
  384. PHW_STREAM_REQUEST_BLOCK pSrb
  385. )
  386. {
  387. NTSTATUS status;
  388. PDCAM_EXTENSION pDevExt = (PDCAM_EXTENSION) pSrb->HwDeviceExtension;
  389. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  390. PKSPROPERTY_VIDEOPROCAMP_S pS = (PKSPROPERTY_VIDEOPROCAMP_S) pSPD->PropertyInfo; // pointer to the data
  391. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEOPROCAMP_S));
  392. switch (pSPD->Property->Id) {
  393. case KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS:
  394. status = DCamSetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Brightness), pS->Flags, pS->Value, &pDevExt->DevProperty[ENUM_BRIGHTNESS].Feature, &pDevExt->DevProperty[ENUM_BRIGHTNESS].StatusNControl);
  395. break;
  396. case KSPROPERTY_VIDEOPROCAMP_SHARPNESS:
  397. status = DCamSetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Sharpness), pS->Flags, pS->Value, &pDevExt->DevProperty[ENUM_SHARPNESS].Feature, &pDevExt->DevProperty[ENUM_SHARPNESS].StatusNControl);
  398. break;
  399. case KSPROPERTY_VIDEOPROCAMP_HUE:
  400. status = DCamSetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Hue), pS->Flags, pS->Value, &pDevExt->DevProperty[ENUM_HUE].Feature, &pDevExt->DevProperty[ENUM_HUE].StatusNControl);
  401. break;
  402. case KSPROPERTY_VIDEOPROCAMP_SATURATION:
  403. status = DCamSetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Saturation), pS->Flags, pS->Value, &pDevExt->DevProperty[ENUM_SATURATION].Feature, &pDevExt->DevProperty[ENUM_SATURATION].StatusNControl);
  404. break;
  405. case KSPROPERTY_VIDEOPROCAMP_WHITEBALANCE:
  406. status = DCamSetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, WhiteBalance), pS->Flags, pS->Value, &pDevExt->DevProperty[ENUM_WHITEBALANCE].Feature, &pDevExt->DevProperty[ENUM_WHITEBALANCE].StatusNControl);
  407. break;
  408. default:
  409. status = STATUS_NOT_IMPLEMENTED;
  410. break;
  411. }
  412. pSrb->Status = status;
  413. pSrb->ActualBytesTransferred = (status == STATUS_SUCCESS ? sizeof (KSPROPERTY_VIDEOPROCAMP_S) : 0);
  414. }
  415. /*
  416. ** AdapterSetCameraControlProperty ()
  417. **
  418. ** Handles Set operations on the CameraControl property set.
  419. **
  420. ** Arguments:
  421. **
  422. ** pSRB -
  423. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  424. **
  425. ** Returns:
  426. **
  427. ** Side Effects: none
  428. */
  429. VOID
  430. AdapterSetCameraControlProperty(
  431. PHW_STREAM_REQUEST_BLOCK pSrb
  432. )
  433. {
  434. NTSTATUS status;
  435. PDCAM_EXTENSION pDevExt = (PDCAM_EXTENSION) pSrb->HwDeviceExtension;
  436. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  437. PKSPROPERTY_CAMERACONTROL_S pS = (PKSPROPERTY_CAMERACONTROL_S) pSPD->PropertyInfo; // pointer to the data
  438. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_CAMERACONTROL_S));
  439. switch (pSPD->Property->Id) {
  440. case KSPROPERTY_CAMERACONTROL_FOCUS:
  441. status = DCamSetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Focus), pS->Flags, pS->Value, &pDevExt->DevProperty[ENUM_FOCUS].Feature, &pDevExt->DevProperty[ENUM_FOCUS].StatusNControl);
  442. break;
  443. case KSPROPERTY_CAMERACONTROL_ZOOM:
  444. status = DCamSetProperty((PIRB) pSrb->SRBExtension, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Zoom), pS->Flags, pS->Value, &pDevExt->DevProperty[ENUM_ZOOM].Feature, &pDevExt->DevProperty[ENUM_ZOOM].StatusNControl);
  445. break;
  446. default:
  447. status = STATUS_NOT_IMPLEMENTED;
  448. break;
  449. }
  450. pSrb->Status = status;
  451. pSrb->ActualBytesTransferred = (status == STATUS_SUCCESS ? sizeof (KSPROPERTY_CAMERACONTROL_S) : 0);
  452. }
  453. /*
  454. ** AdapterSetProperty ()
  455. **
  456. ** Handles Get operations for all adapter properties.
  457. **
  458. ** Arguments:
  459. **
  460. ** pSRB -
  461. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  462. **
  463. ** Returns:
  464. **
  465. ** Side Effects: none
  466. */
  467. VOID
  468. STREAMAPI
  469. AdapterSetProperty(
  470. PHW_STREAM_REQUEST_BLOCK pSrb
  471. )
  472. {
  473. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  474. if (IsEqualGUID(&PROPSETID_VIDCAP_VIDEOPROCAMP, &pSPD->Property->Set)) {
  475. AdapterSetVideoProcAmpProperty (pSrb);
  476. } else if (IsEqualGUID(&PROPSETID_VIDCAP_CAMERACONTROL, &pSPD->Property->Set)) {
  477. AdapterSetCameraControlProperty (pSrb);
  478. } else {
  479. //
  480. // We should never get here
  481. //
  482. ASSERT(FALSE);
  483. }
  484. }
  485. NTSTATUS
  486. CreateRegistryKeySingle(
  487. IN HANDLE hKey,
  488. IN ACCESS_MASK desiredAccess,
  489. PWCHAR pwszSection,
  490. OUT PHANDLE phKeySection
  491. )
  492. {
  493. NTSTATUS status;
  494. UNICODE_STRING ustr;
  495. OBJECT_ATTRIBUTES objectAttributes;
  496. RtlInitUnicodeString(&ustr, pwszSection);
  497. InitializeObjectAttributes(
  498. &objectAttributes,
  499. &ustr,
  500. OBJ_CASE_INSENSITIVE,
  501. hKey,
  502. NULL
  503. );
  504. status =
  505. ZwCreateKey(
  506. phKeySection,
  507. desiredAccess,
  508. &objectAttributes,
  509. 0,
  510. NULL, /* optional*/
  511. REG_OPTION_NON_VOLATILE,
  512. NULL
  513. );
  514. return status;
  515. }
  516. NTSTATUS
  517. CreateRegistrySubKey(
  518. IN HANDLE hKey,
  519. IN ACCESS_MASK desiredAccess,
  520. PWCHAR pwszSection,
  521. OUT PHANDLE phKeySection
  522. )
  523. {
  524. UNICODE_STRING ustr;
  525. USHORT usPos = 1; // Skip first backslash
  526. static WCHAR wSep = '\\';
  527. NTSTATUS status = STATUS_SUCCESS;
  528. RtlInitUnicodeString(&ustr, pwszSection);
  529. while(usPos < ustr.Length) {
  530. if(ustr.Buffer[usPos] == wSep) {
  531. // NULL terminate our partial string
  532. ustr.Buffer[usPos] = UNICODE_NULL;
  533. status =
  534. CreateRegistryKeySingle(
  535. hKey,
  536. desiredAccess,
  537. ustr.Buffer,
  538. phKeySection
  539. );
  540. ustr.Buffer[usPos] = wSep;
  541. if(NT_SUCCESS(status)) {
  542. ZwClose(*phKeySection);
  543. } else {
  544. break;
  545. }
  546. }
  547. usPos++;
  548. }
  549. // Create the full key
  550. if(NT_SUCCESS(status)) {
  551. status =
  552. CreateRegistryKeySingle(
  553. hKey,
  554. desiredAccess,
  555. ustr.Buffer,
  556. phKeySection
  557. );
  558. }
  559. return status;
  560. }
  561. NTSTATUS
  562. GetRegistryKeyValue (
  563. IN HANDLE Handle,
  564. IN PWCHAR KeyNameString,
  565. IN ULONG KeyNameStringLength,
  566. IN PVOID Data,
  567. IN PULONG DataLength
  568. )
  569. /*++
  570. Routine Description:
  571. This routine gets the specified value out of the registry
  572. Arguments:
  573. Handle - Handle to location in registry
  574. KeyNameString - registry key we're looking for
  575. KeyNameStringLength - length of registry key we're looking for
  576. Data - where to return the data
  577. DataLength - how big the data is
  578. Return Value:
  579. status is returned from ZwQueryValueKey
  580. --*/
  581. {
  582. NTSTATUS status = STATUS_INSUFFICIENT_RESOURCES;
  583. UNICODE_STRING keyName;
  584. ULONG length;
  585. PKEY_VALUE_FULL_INFORMATION fullInfo;
  586. RtlInitUnicodeString(&keyName, KeyNameString);
  587. length = sizeof(KEY_VALUE_FULL_INFORMATION) +
  588. KeyNameStringLength + *DataLength;
  589. fullInfo = ExAllocatePool(PagedPool, length);
  590. if (fullInfo) {
  591. status = ZwQueryValueKey(
  592. Handle,
  593. &keyName,
  594. KeyValueFullInformation,
  595. fullInfo,
  596. length,
  597. &length
  598. );
  599. if (NT_SUCCESS(status)){
  600. ASSERT(fullInfo->DataLength <= *DataLength);
  601. RtlCopyMemory(
  602. Data,
  603. ((PUCHAR) fullInfo) + fullInfo->DataOffset,
  604. fullInfo->DataLength
  605. );
  606. }
  607. *DataLength = fullInfo->DataLength;
  608. ExFreePool(fullInfo);
  609. }
  610. return (status);
  611. }
  612. NTSTATUS
  613. SetRegistryKeyValue(
  614. HANDLE hKey,
  615. PWCHAR pwszEntry,
  616. LONG nValue
  617. )
  618. {
  619. NTSTATUS status;
  620. UNICODE_STRING ustr;
  621. RtlInitUnicodeString(&ustr, pwszEntry);
  622. status =
  623. ZwSetValueKey(
  624. hKey,
  625. &ustr,
  626. 0, /* optional */
  627. REG_DWORD,
  628. &nValue,
  629. sizeof(nValue)
  630. );
  631. return status;
  632. }
  633. BOOL
  634. DCamQueryPropertyFeaturesAndSettings(
  635. IN PIRB pIrb,
  636. PDCAM_EXTENSION pDevExt,
  637. ULONG ulFieldOffset,
  638. DCamRegArea * pFeature,
  639. HANDLE hKeySettings,
  640. PWCHAR pwszPropertyName,
  641. ULONG ulPropertyNameLen,
  642. DCamRegArea * pPropertySettings,
  643. PWCHAR pwszPropertyNameDef,
  644. ULONG ulPropertyNameDefLen,
  645. LONG * plValueDef
  646. )
  647. {
  648. NTSTATUS Status = STATUS_SUCCESS;
  649. ULONG ulLength;
  650. DCamRegArea RegDefault;
  651. // Reset settings.
  652. pFeature->AsULONG = 0;
  653. pPropertySettings->AsULONG = 0;
  654. // Read feature of this property
  655. Status = DCamReadRegister(pIrb, pDevExt, ulFieldOffset-QUERY_ADDR_OFFSET, &(pFeature->AsULONG));
  656. if(NT_SUCCESS(Status)) {
  657. pFeature->AsULONG = bswap(pFeature->AsULONG);
  658. if(pFeature->Feature.PresenceInq == 0) {
  659. ERROR_LOG(("\'%S not supported; Reset property settings\n", pwszPropertyName));
  660. return FALSE;
  661. }
  662. } else {
  663. ERROR_LOG(("\'ST:%x reading register\n", Status));
  664. return FALSE;
  665. }
  666. // Get persisted settings saved in the registry; (if it not defined, it is initialize to 0).
  667. ulLength = sizeof(LONG);
  668. Status = GetRegistryKeyValue(
  669. hKeySettings,
  670. pwszPropertyName,
  671. ulPropertyNameLen,
  672. (PVOID) pPropertySettings,
  673. &ulLength
  674. );
  675. if(NT_SUCCESS(Status)) {
  676. // Detect if AutoMode was mistakenly set by the registry.
  677. if(pPropertySettings->Brightness.AutoMode == 1 && pFeature->Feature.AutoMode == 0) {
  678. ERROR_LOG(("\'Detect %s AutoMode mistakenly set\n", pwszPropertyName));
  679. pPropertySettings->Brightness.AutoMode = 0;
  680. }
  681. // Detect out of range and set it to mid range.
  682. if(pPropertySettings->Brightness.Value < pFeature->Feature.MIN_Value ||
  683. pFeature->Feature.MAX_Value < pPropertySettings->Brightness.Value) {
  684. ERROR_LOG(("\'Detect %S out of range %d not within (%d,%d)\n",
  685. pwszPropertyName,
  686. pPropertySettings->Brightness.Value,
  687. pFeature->Feature.MIN_Value,
  688. pFeature->Feature.MAX_Value));
  689. pPropertySettings->Brightness.Value = (pFeature->Feature.MIN_Value + pFeature->Feature.MAX_Value)/2;
  690. }
  691. // Query default value
  692. ulLength = sizeof(LONG);
  693. RegDefault.AsULONG = 0;
  694. *plValueDef = 0;
  695. Status = GetRegistryKeyValue(
  696. hKeySettings,
  697. pwszPropertyNameDef,
  698. ulPropertyNameDefLen,
  699. (PVOID) &RegDefault,
  700. &ulLength
  701. );
  702. if(NT_SUCCESS(Status)) {
  703. // Make sure that the default is within the range
  704. if(RegDefault.Brightness.Value < pFeature->Feature.MIN_Value ||
  705. pFeature->Feature.MAX_Value < RegDefault.Brightness.Value) {
  706. ERROR_LOG(("\'%S %d out of range (%d, %d), set to midrange.\n",
  707. pwszPropertyNameDef,
  708. RegDefault.Brightness.Value,
  709. pFeature->Feature.MIN_Value,
  710. pFeature->Feature.MAX_Value));
  711. *plValueDef = (LONG) (pFeature->Feature.MIN_Value + pFeature->Feature.MAX_Value)/2;
  712. } else {
  713. *plValueDef = (LONG) RegDefault.Brightness.Value;
  714. }
  715. } else {
  716. ERROR_LOG(("\'Read Registry failed! ST:%x; %S; Offset:%d\n", Status, pwszPropertyNameDef, ulFieldOffset));
  717. *plValueDef = (LONG) (pFeature->Feature.MIN_Value + pFeature->Feature.MAX_Value)/2;
  718. // Set default so return success too.
  719. Status = STATUS_SUCCESS;
  720. }
  721. } else {
  722. // If registry key is not in the registry key, we will initialize it to
  723. // always use the auto mode, and its value (and the default) in midrange.
  724. ERROR_LOG(("\'Read Registry failed! ST:%x; %S; Offset:%d\n", Status, pwszPropertyName, ulFieldOffset));
  725. pPropertySettings->Brightness.AutoMode = pFeature->Feature.AutoMode;
  726. pPropertySettings->Brightness.Value = (pFeature->Feature.MIN_Value + pFeature->Feature.MAX_Value)/2;
  727. *plValueDef = (LONG) (pFeature->Feature.MIN_Value + pFeature->Feature.MAX_Value)/2;
  728. // Set default so return success too.
  729. Status = STATUS_SUCCESS;
  730. }
  731. #if DBG
  732. // Print out a summary of this property setting, include:
  733. // Features, current setting, and persisted values.
  734. DCamReadRegister(pIrb, pDevExt, ulFieldOffset, &(pDevExt->RegArea.AsULONG));
  735. pDevExt->RegArea.AsULONG = bswap(pDevExt->RegArea.AsULONG);
  736. DbgMsg1(("\'***** St:%x; %S (offset:%d)\n", Status, pwszPropertyName, ulFieldOffset));
  737. DbgMsg1(("\'Feature: %x; Pres:%d; OnePush:%d; ReadOut:%d; OnOff;%d; (A:%d; M:%d); (%d..%d)\n",
  738. pFeature->AsULONG,
  739. pFeature->Feature.PresenceInq,
  740. pFeature->Feature.OnePush,
  741. pFeature->Feature.ReadOut_Inq,
  742. pFeature->Feature.OnOff,
  743. pFeature->Feature.AutoMode,
  744. pFeature->Feature.ManualMode,
  745. pFeature->Feature.MIN_Value,
  746. pFeature->Feature.MAX_Value
  747. ));
  748. DbgMsg1(("\'Setting: %.8x; Pres:%d; OnePush:%d; OnOff;%d; Auto:%d; (%d;%d)\n",
  749. pDevExt->RegArea.AsULONG,
  750. pDevExt->RegArea.WhiteBalance.PresenceInq,
  751. pDevExt->RegArea.WhiteBalance.OnePush,
  752. pDevExt->RegArea.WhiteBalance.OnOff,
  753. pDevExt->RegArea.WhiteBalance.AutoMode,
  754. pDevExt->RegArea.WhiteBalance.UValue,
  755. pDevExt->RegArea.WhiteBalance.VValue
  756. ));
  757. DbgMsg1(("\'Registry:%.8x; Pres:%d; OnePush:%d; OnOff;%d; Auto:%d; (%d;%d)\n\n",
  758. pPropertySettings->AsULONG,
  759. pPropertySettings->WhiteBalance.PresenceInq,
  760. pPropertySettings->WhiteBalance.OnePush,
  761. pPropertySettings->WhiteBalance.OnOff,
  762. pPropertySettings->WhiteBalance.AutoMode,
  763. pPropertySettings->WhiteBalance.UValue,
  764. pPropertySettings->WhiteBalance.VValue
  765. ));
  766. #endif
  767. return NT_SUCCESS(Status);
  768. }
  769. BOOL
  770. DCamGetPropertyValuesFromRegistry(
  771. PDCAM_EXTENSION pDevExt
  772. )
  773. {
  774. NTSTATUS Status;
  775. HANDLE hPDOKey, hKeySettings;
  776. PIRB pIrb;
  777. ULONG ulLength;
  778. DbgMsg2(("\'GetPropertyValuesFromRegistry: pDevExt=%x; pDevExt->BusDeviceObject=%x\n", pDevExt, pDevExt->BusDeviceObject));
  779. pIrb = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRB), 'macd');
  780. if(!pIrb)
  781. return FALSE;
  782. //
  783. // Registry key:
  784. // Windows 2000:
  785. // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\
  786. // {6BDD1FC6-810F-11D0-BEC7-08002BE2092F\000x
  787. //
  788. // Win98:
  789. // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Class\Image\000x
  790. //
  791. Status =
  792. IoOpenDeviceRegistryKey(
  793. pDevExt->PhysicalDeviceObject,
  794. PLUGPLAY_REGKEY_DRIVER,
  795. STANDARD_RIGHTS_READ,
  796. &hPDOKey);
  797. // Can fail only if PDO might be deleted due to device removal.
  798. ASSERT(!pDevExt->bDevRemoved && Status == STATUS_SUCCESS);
  799. //
  800. // loop through our table of strings,
  801. // reading the registry for each.
  802. //
  803. if(!NT_SUCCESS(Status)) {
  804. ERROR_LOG(("\'GetPropertyValuesFromRegistry: IoOpenDeviceRegistryKey failed with Status=%x\n", Status));
  805. ExFreePool(pIrb); pIrb = NULL;
  806. return FALSE;
  807. }
  808. //
  809. // Create or open the settings key
  810. //
  811. Status =
  812. CreateRegistrySubKey(
  813. hPDOKey,
  814. KEY_ALL_ACCESS,
  815. wszSettings,
  816. &hKeySettings
  817. );
  818. if(!NT_SUCCESS(Status)) {
  819. ERROR_LOG(("\'GetPropertyValuesFromRegistry: CreateRegistrySubKey failed with Status=%x\n", Status));
  820. ZwClose(hPDOKey);
  821. return FALSE;
  822. }
  823. // Get persisted settings saved in the registry; (if it not defined, it is initialize to 0).
  824. //
  825. // Read from registry to find out what compression formats are supported
  826. // by the decoder installed on this system. This registry key can be altered
  827. // if IHV/ISV add additional decoder. Currently, Microsft's MSYUV supports
  828. // only UYVY format.
  829. //
  830. pDevExt->DecoderDCamVModeInq0.AsULONG = 0;
  831. ulLength = sizeof(LONG);
  832. Status = GetRegistryKeyValue(
  833. hKeySettings,
  834. wszVModeInq0,
  835. sizeof(wszVModeInq0),
  836. (PVOID) &pDevExt->DecoderDCamVModeInq0,
  837. &ulLength
  838. );
  839. if(NT_SUCCESS(Status)) {
  840. pDevExt->DecoderDCamVModeInq0.AsULONG = bswap(pDevExt->DecoderDCamVModeInq0.AsULONG);
  841. DbgMsg1(("\'Modes supported by the decoder: %x\n [0]:%d\n [1]:%d\n [2]:%d\n [3]:%d\n [4]:%d\n [5]:%d\n",
  842. pDevExt->DecoderDCamVModeInq0.AsULONG,
  843. pDevExt->DecoderDCamVModeInq0.VMode.Mode0,
  844. pDevExt->DecoderDCamVModeInq0.VMode.Mode1,
  845. pDevExt->DecoderDCamVModeInq0.VMode.Mode2,
  846. pDevExt->DecoderDCamVModeInq0.VMode.Mode3,
  847. pDevExt->DecoderDCamVModeInq0.VMode.Mode4,
  848. pDevExt->DecoderDCamVModeInq0.VMode.Mode5
  849. ));
  850. } else {
  851. ERROR_LOG(("\'Failed to read VModeInq0 registery: %x\n", Status));
  852. }
  853. // MSYUV supports these modes; always turn them on.
  854. pDevExt->DecoderDCamVModeInq0.VMode.Mode1 = 1; // MSYUV.dll:(UYVY:320x480)
  855. pDevExt->DecoderDCamVModeInq0.VMode.Mode3 = 1; // MSYUV.dll:(UYVY:640x480)
  856. #ifdef SUPPORT_RGB24
  857. pDevExt->DecoderDCamVModeInq0.VMode.Mode4 = 1; // MSYUV.dll:(RGB24:640x480)
  858. #endif
  859. #if DBG
  860. pDevExt->DevFeature1.AsULONG = 0;
  861. Status = DCamReadRegister(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, FeaturePresent1), &pDevExt->DevFeature1.AsULONG);
  862. if(NT_SUCCESS(Status)) {
  863. pDevExt->DevFeature1.AsULONG = bswap(pDevExt->DevFeature1.AsULONG);
  864. DbgMsg1(("\'Features1: %x:\n Brightness:%d;\n Exposure:%d\n Sharpness:%d\n WhiteBalance:%d\n Hue:%d;\n Saturation:%d;\n Gamma:%d\n Shutter:%d\n Gain:%d\n Iris:%d\n Focus:%d\n",
  865. pDevExt->DevFeature1.AsULONG,
  866. pDevExt->DevFeature1.CameraCap1.Brightness,
  867. pDevExt->DevFeature1.CameraCap1.Exposure,
  868. pDevExt->DevFeature1.CameraCap1.Sharpness,
  869. pDevExt->DevFeature1.CameraCap1.White_Balance,
  870. pDevExt->DevFeature1.CameraCap1.Hue,
  871. pDevExt->DevFeature1.CameraCap1.Saturation,
  872. pDevExt->DevFeature1.CameraCap1.Gamma,
  873. pDevExt->DevFeature1.CameraCap1.Shutter,
  874. pDevExt->DevFeature1.CameraCap1.Gain,
  875. pDevExt->DevFeature1.CameraCap1.Iris,
  876. pDevExt->DevFeature1.CameraCap1.Focus
  877. ));
  878. } else {
  879. ERROR_LOG(("\'Failed to read Feature1 register: %x\n", Status));
  880. }
  881. pDevExt->DevFeature2.AsULONG = 0;
  882. Status = DCamReadRegister(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, FeaturePresent2), &pDevExt->DevFeature1.AsULONG);
  883. if(NT_SUCCESS(Status)) {
  884. pDevExt->DevFeature2.AsULONG = bswap(pDevExt->DevFeature2.AsULONG);
  885. DbgMsg1(("\'Features2: %x\n Zoom:%d\n Pan:%d\n Tile:%d\n",
  886. pDevExt->DevFeature2.AsULONG,
  887. pDevExt->DevFeature2.CameraCap2.Zoom,
  888. pDevExt->DevFeature2.CameraCap2.Pan,
  889. pDevExt->DevFeature1.CameraCap2.Tile
  890. ));
  891. } else {
  892. ERROR_LOG(("\'Failed to read Feature2 register: %x\n", Status));
  893. }
  894. #endif
  895. // Brightness
  896. if(DCamQueryPropertyFeaturesAndSettings(
  897. pIrb,
  898. pDevExt,
  899. FIELDOFFSET(CAMERA_REGISTER_MAP, Brightness),
  900. &pDevExt->DevProperty[ENUM_BRIGHTNESS].Feature,
  901. hKeySettings,
  902. wszBrightness,
  903. sizeof(wszBrightness),
  904. &pDevExt->DevProperty[ENUM_BRIGHTNESS].StatusNControl,
  905. wszBrightnessDef,
  906. sizeof(wszBrightnessDef),
  907. &pDevExt->DevProperty[ENUM_BRIGHTNESS].DefaultValue
  908. )) {
  909. pDevExt->DevProperty[ENUM_BRIGHTNESS].RangeNStep.Bounds.SignedMinimum = pDevExt->DevProperty[ENUM_BRIGHTNESS].Feature.Feature.MIN_Value;
  910. pDevExt->DevProperty[ENUM_BRIGHTNESS].RangeNStep.Bounds.SignedMaximum = pDevExt->DevProperty[ENUM_BRIGHTNESS].Feature.Feature.MAX_Value;
  911. pDevExt->DevPropDefine[ENUM_BRIGHTNESS].Range.Members = (VOID*) &pDevExt->DevProperty[ENUM_BRIGHTNESS].RangeNStep;
  912. pDevExt->DevPropDefine[ENUM_BRIGHTNESS].Default.Members = (VOID*) &pDevExt->DevProperty[ENUM_BRIGHTNESS].DefaultValue;
  913. } else {
  914. pDevExt->VideoProcAmpItems[ENUM_BRIGHTNESS].GetSupported = FALSE;
  915. pDevExt->VideoProcAmpItems[ENUM_BRIGHTNESS].SetSupported = FALSE;
  916. }
  917. // Saturation
  918. if(DCamQueryPropertyFeaturesAndSettings(
  919. pIrb,
  920. pDevExt,
  921. FIELDOFFSET(CAMERA_REGISTER_MAP, Saturation),
  922. &pDevExt->DevProperty[ENUM_SATURATION].Feature,
  923. hKeySettings,
  924. wszSaturation,
  925. sizeof(wszSaturation),
  926. &pDevExt->DevProperty[ENUM_SATURATION].StatusNControl,
  927. wszSaturationDef,
  928. sizeof(wszSaturationDef),
  929. &pDevExt->DevProperty[ENUM_SATURATION].DefaultValue
  930. )) {
  931. pDevExt->DevProperty[ENUM_SATURATION].RangeNStep.Bounds.SignedMinimum = pDevExt->DevProperty[ENUM_SATURATION].Feature.Feature.MIN_Value;
  932. pDevExt->DevProperty[ENUM_SATURATION].RangeNStep.Bounds.SignedMaximum = pDevExt->DevProperty[ENUM_SATURATION].Feature.Feature.MAX_Value;
  933. pDevExt->DevPropDefine[ENUM_SATURATION].Range.Members = (VOID*) &pDevExt->DevProperty[ENUM_SATURATION].RangeNStep;
  934. pDevExt->DevPropDefine[ENUM_SATURATION].Default.Members = (VOID*) &pDevExt->DevProperty[ENUM_SATURATION].DefaultValue;
  935. } else {
  936. pDevExt->VideoProcAmpItems[ENUM_SATURATION].GetSupported = FALSE;
  937. pDevExt->VideoProcAmpItems[ENUM_SATURATION].SetSupported = FALSE;
  938. }
  939. // Hue
  940. if(DCamQueryPropertyFeaturesAndSettings(
  941. pIrb,
  942. pDevExt,
  943. FIELDOFFSET(CAMERA_REGISTER_MAP, Hue),
  944. &pDevExt->DevProperty[ENUM_HUE].Feature,
  945. hKeySettings,
  946. wszHue,
  947. sizeof(wszHue),
  948. &pDevExt->DevProperty[ENUM_HUE].StatusNControl,
  949. wszHueDef,
  950. sizeof(wszHueDef),
  951. &pDevExt->DevProperty[ENUM_HUE].DefaultValue
  952. )) {
  953. pDevExt->DevProperty[ENUM_HUE].RangeNStep.Bounds.SignedMinimum = pDevExt->DevProperty[ENUM_HUE].Feature.Feature.MIN_Value;
  954. pDevExt->DevProperty[ENUM_HUE].RangeNStep.Bounds.SignedMaximum = pDevExt->DevProperty[ENUM_HUE].Feature.Feature.MAX_Value;
  955. pDevExt->DevPropDefine[ENUM_HUE].Range.Members = (VOID*) &pDevExt->DevProperty[ENUM_HUE].RangeNStep;
  956. pDevExt->DevPropDefine[ENUM_HUE].Default.Members = (VOID*) &pDevExt->DevProperty[ENUM_HUE].DefaultValue;
  957. } else {
  958. pDevExt->VideoProcAmpItems[ENUM_HUE].GetSupported = FALSE;
  959. pDevExt->VideoProcAmpItems[ENUM_HUE].SetSupported = FALSE;
  960. }
  961. // Sharpness
  962. if(DCamQueryPropertyFeaturesAndSettings(
  963. pIrb,
  964. pDevExt,
  965. FIELDOFFSET(CAMERA_REGISTER_MAP, Sharpness),
  966. &pDevExt->DevProperty[ENUM_SHARPNESS].Feature,
  967. hKeySettings,
  968. wszSharpness,
  969. sizeof(wszSharpness),
  970. &pDevExt->DevProperty[ENUM_SHARPNESS].StatusNControl,
  971. wszSharpnessDef,
  972. sizeof(wszSharpnessDef),
  973. &pDevExt->DevProperty[ENUM_SHARPNESS].DefaultValue
  974. )) {
  975. pDevExt->DevProperty[ENUM_SHARPNESS].RangeNStep.Bounds.SignedMinimum = pDevExt->DevProperty[ENUM_SHARPNESS].Feature.Feature.MIN_Value;
  976. pDevExt->DevProperty[ENUM_SHARPNESS].RangeNStep.Bounds.SignedMaximum = pDevExt->DevProperty[ENUM_SHARPNESS].Feature.Feature.MAX_Value;
  977. pDevExt->DevPropDefine[ENUM_SHARPNESS].Range.Members = (VOID*) &pDevExt->DevProperty[ENUM_SHARPNESS].RangeNStep;
  978. pDevExt->DevPropDefine[ENUM_SHARPNESS].Default.Members = (VOID*) &pDevExt->DevProperty[ENUM_SHARPNESS].DefaultValue;
  979. } else {
  980. pDevExt->VideoProcAmpItems[ENUM_SHARPNESS].GetSupported = FALSE;
  981. pDevExt->VideoProcAmpItems[ENUM_SHARPNESS].SetSupported = FALSE;
  982. }
  983. // WhiteBalance
  984. if(DCamQueryPropertyFeaturesAndSettings(
  985. pIrb,
  986. pDevExt,
  987. FIELDOFFSET(CAMERA_REGISTER_MAP, WhiteBalance),
  988. &pDevExt->DevProperty[ENUM_WHITEBALANCE].Feature,
  989. hKeySettings,
  990. wszWhiteBalance,
  991. sizeof(wszWhiteBalance),
  992. &pDevExt->DevProperty[ENUM_WHITEBALANCE].StatusNControl,
  993. wszWhiteBalanceDef,
  994. sizeof(wszWhiteBalanceDef),
  995. &pDevExt->DevProperty[ENUM_WHITEBALANCE].DefaultValue
  996. )) {
  997. pDevExt->DevProperty[ENUM_WHITEBALANCE].RangeNStep.Bounds.SignedMinimum = pDevExt->DevProperty[ENUM_WHITEBALANCE].Feature.Feature.MIN_Value;
  998. pDevExt->DevProperty[ENUM_WHITEBALANCE].RangeNStep.Bounds.SignedMaximum = pDevExt->DevProperty[ENUM_WHITEBALANCE].Feature.Feature.MAX_Value;
  999. pDevExt->DevPropDefine[ENUM_WHITEBALANCE].Range.Members = (VOID*) &pDevExt->DevProperty[ENUM_WHITEBALANCE].RangeNStep;
  1000. pDevExt->DevPropDefine[ENUM_WHITEBALANCE].Default.Members = (VOID*) &pDevExt->DevProperty[ENUM_WHITEBALANCE].DefaultValue;
  1001. } else {
  1002. pDevExt->VideoProcAmpItems[ENUM_WHITEBALANCE].GetSupported = FALSE;
  1003. pDevExt->VideoProcAmpItems[ENUM_WHITEBALANCE].SetSupported = FALSE;
  1004. }
  1005. // Zoom
  1006. if(DCamQueryPropertyFeaturesAndSettings(
  1007. pIrb,
  1008. pDevExt,
  1009. FIELDOFFSET(CAMERA_REGISTER_MAP, Zoom),
  1010. &pDevExt->DevProperty[ENUM_ZOOM].Feature,
  1011. hKeySettings,
  1012. wszZoom,
  1013. sizeof(wszZoom),
  1014. &pDevExt->DevProperty[ENUM_ZOOM].StatusNControl,
  1015. wszZoomDef,
  1016. sizeof(wszZoomDef),
  1017. &pDevExt->DevProperty[ENUM_ZOOM].DefaultValue
  1018. )) {
  1019. pDevExt->DevProperty[ENUM_ZOOM].RangeNStep.Bounds.SignedMinimum = pDevExt->DevProperty[ENUM_ZOOM].Feature.Feature.MIN_Value;
  1020. pDevExt->DevProperty[ENUM_ZOOM].RangeNStep.Bounds.SignedMaximum = pDevExt->DevProperty[ENUM_ZOOM].Feature.Feature.MAX_Value;
  1021. pDevExt->DevPropDefine[ENUM_ZOOM].Range.Members = (VOID*) &pDevExt->DevProperty[ENUM_ZOOM].RangeNStep;
  1022. pDevExt->DevPropDefine[ENUM_ZOOM].Default.Members = (VOID*) &pDevExt->DevProperty[ENUM_ZOOM].DefaultValue;
  1023. } else {
  1024. pDevExt->VideoProcAmpItems[ENUM_ZOOM].GetSupported = FALSE;
  1025. pDevExt->VideoProcAmpItems[ENUM_ZOOM].SetSupported = FALSE;
  1026. }
  1027. // Focus
  1028. if(DCamQueryPropertyFeaturesAndSettings(
  1029. pIrb,
  1030. pDevExt,
  1031. FIELDOFFSET(CAMERA_REGISTER_MAP, Focus),
  1032. &pDevExt->DevProperty[ENUM_FOCUS].Feature,
  1033. hKeySettings,
  1034. wszFocus,
  1035. sizeof(wszFocus),
  1036. &pDevExt->DevProperty[ENUM_FOCUS].StatusNControl,
  1037. wszFocusDef,
  1038. sizeof(wszFocusDef),
  1039. &pDevExt->DevProperty[ENUM_FOCUS].DefaultValue
  1040. )) {
  1041. pDevExt->DevProperty[ENUM_FOCUS].RangeNStep.Bounds.SignedMinimum = pDevExt->DevProperty[ENUM_FOCUS].Feature.Feature.MIN_Value;
  1042. pDevExt->DevProperty[ENUM_FOCUS].RangeNStep.Bounds.SignedMaximum = pDevExt->DevProperty[ENUM_FOCUS].Feature.Feature.MAX_Value;
  1043. pDevExt->DevPropDefine[ENUM_FOCUS].Range.Members = (VOID*) &pDevExt->DevProperty[ENUM_FOCUS].RangeNStep;
  1044. pDevExt->DevPropDefine[ENUM_FOCUS].Default.Members = (VOID*) &pDevExt->DevProperty[ENUM_FOCUS].DefaultValue;
  1045. } else {
  1046. pDevExt->VideoProcAmpItems[ENUM_FOCUS].GetSupported = FALSE;
  1047. pDevExt->VideoProcAmpItems[ENUM_FOCUS].SetSupported = FALSE;
  1048. }
  1049. ZwClose(hKeySettings);
  1050. ZwClose(hPDOKey);
  1051. ExFreePool(pIrb); pIrb = NULL;
  1052. return TRUE;
  1053. }
  1054. BOOL
  1055. DCamSetPropertyValuesToRegistry(
  1056. PDCAM_EXTENSION pDevExt
  1057. )
  1058. {
  1059. // Set the default to :
  1060. // HLM\Software\DeviceExtension->pchVendorName\1394DCam
  1061. NTSTATUS Status;
  1062. HANDLE hPDOKey, hKeySettings;
  1063. DbgMsg2(("\'SetPropertyValuesToRegistry: pDevExt=%x; pDevExt->BusDeviceObject=%x\n", pDevExt, pDevExt->BusDeviceObject));
  1064. //
  1065. // Registry key:
  1066. // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\
  1067. // {6BDD1FC6-810F-11D0-BEC7-08002BE2092F\000x
  1068. //
  1069. Status =
  1070. IoOpenDeviceRegistryKey(
  1071. pDevExt->PhysicalDeviceObject,
  1072. PLUGPLAY_REGKEY_DRIVER,
  1073. STANDARD_RIGHTS_WRITE,
  1074. &hPDOKey);
  1075. // PDO might be deleted when it was removed.
  1076. if(! pDevExt->bDevRemoved) {
  1077. ASSERT(Status == STATUS_SUCCESS);
  1078. }
  1079. //
  1080. // reading the feature and registry setting for each property
  1081. //
  1082. if(NT_SUCCESS(Status)) {
  1083. // Create or open the settings key
  1084. Status =
  1085. CreateRegistrySubKey(
  1086. hPDOKey,
  1087. KEY_ALL_ACCESS,
  1088. wszSettings,
  1089. &hKeySettings
  1090. );
  1091. if(NT_SUCCESS(Status)) {
  1092. // Brightness
  1093. Status = SetRegistryKeyValue(
  1094. hKeySettings,
  1095. wszBrightness,
  1096. pDevExt->DevProperty[ENUM_BRIGHTNESS].StatusNControl.AsULONG);
  1097. DbgMsg2(("\'SetPropertyValuesToRegistry: Status %x, Brightness %d\n", Status, pDevExt->DevProperty[ENUM_BRIGHTNESS].StatusNControl.AsULONG));
  1098. // Hue
  1099. Status = SetRegistryKeyValue(
  1100. hKeySettings,
  1101. wszHue,
  1102. pDevExt->DevProperty[ENUM_HUE].StatusNControl.AsULONG);
  1103. DbgMsg2(("\'SetPropertyValuesToRegistry: Status %x, Hue %d\n", Status, pDevExt->DevProperty[ENUM_HUE].StatusNControl.AsULONG));
  1104. // Saturation
  1105. Status = SetRegistryKeyValue(
  1106. hKeySettings,
  1107. wszSaturation,
  1108. pDevExt->DevProperty[ENUM_SATURATION].StatusNControl.AsULONG);
  1109. DbgMsg2(("\'SetPropertyValuesToRegistry: Status %x, Saturation %d\n", Status, pDevExt->DevProperty[ENUM_SATURATION].StatusNControl.AsULONG));
  1110. // Sharpness
  1111. Status = SetRegistryKeyValue(
  1112. hKeySettings,
  1113. wszSharpness,
  1114. pDevExt->DevProperty[ENUM_SHARPNESS].StatusNControl.AsULONG);
  1115. DbgMsg2(("\'SetPropertyValuesToRegistry: Status %x, Sharpness %d\n", Status, pDevExt->DevProperty[ENUM_SHARPNESS].StatusNControl.AsULONG));
  1116. // WhiteBalance
  1117. Status = SetRegistryKeyValue(
  1118. hKeySettings,
  1119. wszWhiteBalance,
  1120. pDevExt->DevProperty[ENUM_WHITEBALANCE].StatusNControl.AsULONG);
  1121. DbgMsg2(("\'SetPropertyValuesToRegistry: Status %x, WhiteBalance %d\n", Status, pDevExt->DevProperty[ENUM_WHITEBALANCE].StatusNControl.AsULONG));
  1122. // Zoom
  1123. Status = SetRegistryKeyValue(
  1124. hKeySettings,
  1125. wszZoom,
  1126. pDevExt->DevProperty[ENUM_ZOOM].StatusNControl.AsULONG);
  1127. DbgMsg2(("\'SetPropertyValuesToRegistry: Status %x, Zoom %d\n", Status, pDevExt->DevProperty[ENUM_ZOOM].StatusNControl.AsULONG));
  1128. // Focus
  1129. Status = SetRegistryKeyValue(
  1130. hKeySettings,
  1131. wszFocus,
  1132. pDevExt->DevProperty[ENUM_FOCUS].StatusNControl.AsULONG);
  1133. DbgMsg2(("\'SetPropertyValuesToRegistry: Status %x, Focus %d\n", Status, pDevExt->DevProperty[ENUM_FOCUS].StatusNControl.AsULONG));
  1134. ZwClose(hKeySettings);
  1135. ZwClose(hPDOKey);
  1136. return TRUE;
  1137. } else {
  1138. ERROR_LOG(("\'SetPropertyValuesToRegistry: CreateRegistrySubKey failed with Status=%x\n", Status));
  1139. }
  1140. ZwClose(hPDOKey);
  1141. } else {
  1142. DbgMsg2(("\'SetPropertyValuesToRegistry: IoOpenDeviceRegistryKey failed with Status=%x\n", Status));
  1143. }
  1144. return FALSE;
  1145. }
  1146. VOID
  1147. SetCurrentDevicePropertyValues(
  1148. PDCAM_EXTENSION pDevExt,
  1149. PIRB pIrb
  1150. )
  1151. {
  1152. ULONG ulFlags;
  1153. // Set to the last saved values or the defaults
  1154. // VideoProcAmp
  1155. ulFlags = pDevExt->DevProperty[ENUM_BRIGHTNESS].StatusNControl.Brightness.AutoMode ? KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO : KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  1156. DCamSetProperty(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Brightness), ulFlags, pDevExt->DevProperty[ENUM_BRIGHTNESS].StatusNControl.Brightness.Value, &pDevExt->DevProperty[ENUM_BRIGHTNESS].Feature, &pDevExt->DevProperty[ENUM_BRIGHTNESS].StatusNControl);
  1157. ulFlags = pDevExt->DevProperty[ENUM_HUE].StatusNControl.Brightness.AutoMode ? KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO : KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  1158. DCamSetProperty(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Hue), ulFlags, pDevExt->DevProperty[ENUM_HUE].StatusNControl.Brightness.Value, &pDevExt->DevProperty[ENUM_HUE].Feature, &pDevExt->DevProperty[ENUM_HUE].StatusNControl);
  1159. ulFlags = pDevExt->DevProperty[ENUM_SATURATION].StatusNControl.Brightness.AutoMode ? KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO : KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  1160. DCamSetProperty(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Saturation), ulFlags, pDevExt->DevProperty[ENUM_SATURATION].StatusNControl.Brightness.Value, &pDevExt->DevProperty[ENUM_SATURATION].Feature, &pDevExt->DevProperty[ENUM_SATURATION].StatusNControl);
  1161. ulFlags = pDevExt->DevProperty[ENUM_SHARPNESS].StatusNControl.Brightness.AutoMode ? KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO : KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  1162. DCamSetProperty(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Sharpness), ulFlags, pDevExt->DevProperty[ENUM_SHARPNESS].StatusNControl.Brightness.Value, &pDevExt->DevProperty[ENUM_SHARPNESS].Feature, &pDevExt->DevProperty[ENUM_SHARPNESS].StatusNControl);
  1163. ulFlags = pDevExt->DevProperty[ENUM_WHITEBALANCE].StatusNControl.Brightness.AutoMode ? KSPROPERTY_VIDEOPROCAMP_FLAGS_AUTO : KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  1164. DCamSetProperty(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, WhiteBalance),ulFlags, pDevExt->DevProperty[ENUM_WHITEBALANCE].StatusNControl.WhiteBalance.UValue, &pDevExt->DevProperty[ENUM_WHITEBALANCE].Feature, &pDevExt->DevProperty[ENUM_WHITEBALANCE].StatusNControl);
  1165. // CameraControl
  1166. ulFlags = pDevExt->DevProperty[ENUM_ZOOM].StatusNControl.Brightness.AutoMode ? KSPROPERTY_CAMERACONTROL_FLAGS_AUTO : KSPROPERTY_CAMERACONTROL_FLAGS_MANUAL;
  1167. DCamSetProperty(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Zoom), ulFlags, pDevExt->DevProperty[ENUM_ZOOM].StatusNControl.Brightness.Value, &pDevExt->DevProperty[ENUM_ZOOM].Feature, &pDevExt->DevProperty[ENUM_ZOOM].StatusNControl);
  1168. ulFlags = pDevExt->DevProperty[ENUM_FOCUS].StatusNControl.Brightness.AutoMode ? KSPROPERTY_CAMERACONTROL_FLAGS_AUTO : KSPROPERTY_CAMERACONTROL_FLAGS_MANUAL;
  1169. DCamSetProperty(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, Focus), ulFlags, pDevExt->DevProperty[ENUM_FOCUS].StatusNControl.Brightness.Value, &pDevExt->DevProperty[ENUM_FOCUS].Feature, &pDevExt->DevProperty[ENUM_FOCUS].StatusNControl);
  1170. }
  1171. BOOL
  1172. DCamPrepareDevProperties(
  1173. PDCAM_EXTENSION pDevExt
  1174. )
  1175. /*
  1176. Contruct the property table and initialize them to the default value.
  1177. */
  1178. {
  1179. // Initialize property settings (part of the Device Extension)
  1180. // Property Sets: VideoProcAmp and CameraControl sets
  1181. pDevExt->ulPropSetSupported = NUMBER_OF_ADAPTER_PROPERTY_SETS;
  1182. RtlCopyMemory(&pDevExt->VideoProcAmpSet, AdapterPropertyTable, sizeof(KSPROPERTY_SET) * NUMBER_OF_ADAPTER_PROPERTY_SETS);
  1183. pDevExt->VideoProcAmpSet.PropertyItem = &pDevExt->VideoProcAmpItems[0];
  1184. pDevExt->CameraControlSet.PropertyItem = &pDevExt->CameraControlItems[0];
  1185. // Property Items, VideoProcAmp and CameraControl Items
  1186. RtlCopyMemory(&pDevExt->VideoProcAmpItems, VideoProcAmpProperties, sizeof(KSPROPERTY_ITEM) * NUM_VIDEOPROCAMP_ITEMS);
  1187. RtlCopyMemory(&pDevExt->CameraControlItems, CameraControlProperties, sizeof(KSPROPERTY_ITEM) * NUM_CAMERACONTROL_ITEMS);
  1188. // Property values and it member lists (range and default)
  1189. pDevExt->VideoProcAmpItems[ENUM_BRIGHTNESS].Values = &pDevExt->DevPropDefine[ENUM_BRIGHTNESS].Value;
  1190. pDevExt->VideoProcAmpItems[ENUM_SHARPNESS].Values = &pDevExt->DevPropDefine[ENUM_SHARPNESS].Value;
  1191. pDevExt->VideoProcAmpItems[ENUM_HUE].Values = &pDevExt->DevPropDefine[ENUM_HUE].Value;
  1192. pDevExt->VideoProcAmpItems[ENUM_SATURATION].Values = &pDevExt->DevPropDefine[ENUM_SATURATION].Value;
  1193. pDevExt->VideoProcAmpItems[ENUM_WHITEBALANCE].Values = &pDevExt->DevPropDefine[ENUM_WHITEBALANCE].Value;
  1194. //
  1195. pDevExt->VideoProcAmpItems[ENUM_FOCUS].Values = &pDevExt->DevPropDefine[ENUM_FOCUS].Value;
  1196. pDevExt->VideoProcAmpItems[ENUM_ZOOM].Values = &pDevExt->DevPropDefine[ENUM_ZOOM].Value;
  1197. pDevExt->DevPropDefine[ENUM_BRIGHTNESS].Value = BrightnessValues;
  1198. pDevExt->DevPropDefine[ENUM_BRIGHTNESS].Value.MembersList = &pDevExt->DevPropDefine[ENUM_BRIGHTNESS].Range;
  1199. pDevExt->DevPropDefine[ENUM_BRIGHTNESS].Range = BrightnessMembersList[0];
  1200. pDevExt->DevPropDefine[ENUM_BRIGHTNESS].Default = BrightnessMembersList[1];
  1201. pDevExt->DevProperty[ENUM_BRIGHTNESS].RangeNStep = BrightnessRangeAndStep[0];
  1202. pDevExt->DevPropDefine[ENUM_SHARPNESS].Value = SharpnessValues;
  1203. pDevExt->DevPropDefine[ENUM_SHARPNESS].Value.MembersList = &pDevExt->DevPropDefine[ENUM_SHARPNESS].Range;
  1204. pDevExt->DevPropDefine[ENUM_SHARPNESS].Range = SharpnessMembersList[0];
  1205. pDevExt->DevPropDefine[ENUM_SHARPNESS].Default = SharpnessMembersList[1];
  1206. pDevExt->DevProperty[ENUM_SHARPNESS].RangeNStep = SharpnessRangeAndStep[0];
  1207. pDevExt->DevPropDefine[ENUM_HUE].Value = HueValues;
  1208. pDevExt->DevPropDefine[ENUM_HUE].Value.MembersList = &pDevExt->DevPropDefine[ENUM_HUE].Range;
  1209. pDevExt->DevPropDefine[ENUM_HUE].Range = HueMembersList[0];
  1210. pDevExt->DevPropDefine[ENUM_HUE].Default = HueMembersList[1];
  1211. pDevExt->DevProperty[ENUM_HUE].RangeNStep = HueRangeAndStep[0];
  1212. pDevExt->DevPropDefine[ENUM_SATURATION].Value = SaturationValues;
  1213. pDevExt->DevPropDefine[ENUM_SATURATION].Value.MembersList = &pDevExt->DevPropDefine[ENUM_SATURATION].Range;
  1214. pDevExt->DevPropDefine[ENUM_SATURATION].Range = SaturationMembersList[0];
  1215. pDevExt->DevPropDefine[ENUM_SATURATION].Default = SaturationMembersList[1];
  1216. pDevExt->DevProperty[ENUM_SATURATION].RangeNStep = SaturationRangeAndStep[0];
  1217. pDevExt->DevPropDefine[ENUM_WHITEBALANCE].Value = WhiteBalanceValues;
  1218. pDevExt->DevPropDefine[ENUM_WHITEBALANCE].Value.MembersList = &pDevExt->DevPropDefine[ENUM_WHITEBALANCE].Range;
  1219. pDevExt->DevPropDefine[ENUM_WHITEBALANCE].Range = WhiteBalanceMembersList[0];
  1220. pDevExt->DevPropDefine[ENUM_WHITEBALANCE].Default = WhiteBalanceMembersList[1];
  1221. pDevExt->DevProperty[ENUM_WHITEBALANCE].RangeNStep = WhiteBalanceRangeAndStep[0];
  1222. pDevExt->DevPropDefine[ENUM_FOCUS].Value = FocusValues;
  1223. pDevExt->DevPropDefine[ENUM_FOCUS].Value.MembersList = &pDevExt->DevPropDefine[ENUM_FOCUS].Range;
  1224. pDevExt->DevPropDefine[ENUM_FOCUS].Range = FocusMembersList[0];
  1225. pDevExt->DevPropDefine[ENUM_FOCUS].Default = FocusMembersList[1];
  1226. pDevExt->DevProperty[ENUM_FOCUS].RangeNStep = FocusRangeAndStep[0];
  1227. pDevExt->DevPropDefine[ENUM_ZOOM].Value = ZoomValues;
  1228. pDevExt->DevPropDefine[ENUM_ZOOM].Value.MembersList = &pDevExt->DevPropDefine[ENUM_ZOOM].Range;
  1229. pDevExt->DevPropDefine[ENUM_ZOOM].Range = ZoomMembersList[0];
  1230. pDevExt->DevPropDefine[ENUM_ZOOM].Default = ZoomMembersList[1];
  1231. pDevExt->DevProperty[ENUM_ZOOM].RangeNStep = ZoomRangeAndStep[0];
  1232. return STATUS_SUCCESS;
  1233. }
  1234. BOOL
  1235. DCamGetVideoMode(
  1236. PDCAM_EXTENSION pDevExt,
  1237. PIRB pIrb
  1238. )
  1239. /*
  1240. Query Video format and mode supported by the camera.
  1241. */
  1242. {
  1243. NTSTATUS Status;
  1244. // First check if V_MODE_INQ (Format_0) is supported.
  1245. pDevExt->DCamVFormatInq.AsULONG = 0;
  1246. Status = DCamReadRegister(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, VFormat), &(pDevExt->DCamVFormatInq.AsULONG));
  1247. if(NT_SUCCESS(Status)) {
  1248. pDevExt->DCamVFormatInq.AsULONG = bswap(pDevExt->DCamVFormatInq.AsULONG);
  1249. if(pDevExt->DCamVFormatInq.VFormat.Format0 == 1) {
  1250. DbgMsg1(("\'V_FORMAT_INQ %x; Format:[0]:%d; [1]:%d; [2]:%d; [6]:%d; [7]:%d\n",
  1251. pDevExt->DCamVFormatInq.AsULONG,
  1252. pDevExt->DCamVFormatInq.VFormat.Format0,
  1253. pDevExt->DCamVFormatInq.VFormat.Format1,
  1254. pDevExt->DCamVFormatInq.VFormat.Format2,
  1255. pDevExt->DCamVFormatInq.VFormat.Format6,
  1256. pDevExt->DCamVFormatInq.VFormat.Format7
  1257. ));
  1258. pDevExt->DCamVModeInq0.AsULONG = 0;
  1259. Status = DCamReadRegister(pIrb, pDevExt, FIELDOFFSET(CAMERA_REGISTER_MAP, VModeInq[0]), &(pDevExt->DCamVModeInq0.AsULONG));
  1260. if(NT_SUCCESS(Status)) {
  1261. pDevExt->DCamVModeInq0.AsULONG = bswap(pDevExt->DCamVModeInq0.AsULONG);
  1262. DbgMsg1(("\'V_MODE_INQ[0] %x; Mode[]:\n [0](160x120 YUV444):%d\n [1](320x240 YUV422):%d\n [2](640x480 YUV411):%d\n [3](640x480 YUV422):%d\n [4](640x480 RGB24):%d\n [5](640x480 YMono):%d\n",
  1263. pDevExt->DCamVModeInq0.AsULONG,
  1264. pDevExt->DCamVModeInq0.VMode.Mode0,
  1265. pDevExt->DCamVModeInq0.VMode.Mode1,
  1266. pDevExt->DCamVModeInq0.VMode.Mode2,
  1267. pDevExt->DCamVModeInq0.VMode.Mode3,
  1268. pDevExt->DCamVModeInq0.VMode.Mode4,
  1269. pDevExt->DCamVModeInq0.VMode.Mode5
  1270. ));
  1271. } else {
  1272. ERROR_LOG(("\'Read V_MODE_INQ_0 failed:%x!\n", Status))
  1273. }
  1274. } else {
  1275. ERROR_LOG(("\'V_MODE_INQ Format_0 not supported!\n"))
  1276. }
  1277. } else {
  1278. ERROR_LOG(("\'Read V_MODE_INQ failed:%x!\n", Status));
  1279. }
  1280. return NT_SUCCESS(Status);
  1281. }